Skip to content

Commit

Permalink
Cached Object string representation
Browse files Browse the repository at this point in the history
Calling toString on Object may cost a lot. It's much better to
have cached value for it.
  • Loading branch information
matthewtff committed Oct 23, 2015
1 parent 5af881e commit 28c80b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/isPlainObject.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var fnToString = (fn) => Function.prototype.toString.call(fn);
var objStringValue = fnToString(Object);

/**
* @param {any} obj The object to inspect.
Expand All @@ -19,5 +20,5 @@ export default function isPlainObject(obj) {

return typeof constructor === 'function'
&& constructor instanceof constructor
&& fnToString(constructor) === fnToString(Object);
&& fnToString(constructor) === objStringValue;
}

0 comments on commit 28c80b8

Please sign in to comment.