From 28c80b87b8a65a20c4ab655c0f073cdf54353e0f Mon Sep 17 00:00:00 2001 From: Matvey Larionov Date: Fri, 23 Oct 2015 14:27:08 +0300 Subject: [PATCH] Cached Object string representation Calling toString on Object may cost a lot. It's much better to have cached value for it. --- src/utils/isPlainObject.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/isPlainObject.js b/src/utils/isPlainObject.js index db3f6a0113..4a37a2aa2c 100644 --- a/src/utils/isPlainObject.js +++ b/src/utils/isPlainObject.js @@ -1,4 +1,5 @@ var fnToString = (fn) => Function.prototype.toString.call(fn); +var objStringValue = fnToString(Object); /** * @param {any} obj The object to inspect. @@ -19,5 +20,5 @@ export default function isPlainObject(obj) { return typeof constructor === 'function' && constructor instanceof constructor - && fnToString(constructor) === fnToString(Object); + && fnToString(constructor) === objStringValue; }