diff --git a/CHANGELOG b/CHANGELOG index 22e8b2a..76ddd7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove expensive (for such low-level method) internal `getClass` in favor of plain string comparison (kangax) + * Fix `PeriodicalExecuter` so that it no longer suppresses exceptions. [#696 state:resolved] (Samuel Lebeau, Yaffle) * Fix issue related to escaping of selectors for querySelectorAll. [#559 state:resolved] (Jorn Holm) diff --git a/src/lang/object.js b/src/lang/object.js index a9b190e..e6ac732 100644 --- a/src/lang/object.js +++ b/src/lang/object.js @@ -10,10 +10,7 @@ **/ (function() { - function getClass(object) { - return Object.prototype.toString.call(object) - .match(/^\[object\s(.*)\]$/)[1]; - } + var _toString = Object.prototype.toString; /** * Object.extend(destination, source) -> Object @@ -198,7 +195,7 @@ * Returns `true` if `object` is an array; false otherwise. **/ function isArray(object) { - return getClass(object) === "Array"; + return _toString.call(object) == "[object Array]"; } @@ -230,7 +227,7 @@ * Returns `true` if `object` is of type `string`; `false` otherwise. **/ function isString(object) { - return getClass(object) === "String"; + return _toString.call(object) == "[object String]"; } /** @@ -240,7 +237,7 @@ * Returns `true` if `object` is of type `number`; `false` otherwise. **/ function isNumber(object) { - return getClass(object) === "Number"; + return _toString.call(object) == "[object Number]"; } /**