From 409a875c45ad08cf496a5544fc19fce6e0b4410c Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 10 May 2016 18:47:28 +0200 Subject: [PATCH] perf - shave off ~4ms from startup by using a better isObject-implementation --- src/vs/base/common/types.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vs/base/common/types.ts b/src/vs/base/common/types.ts index 0da219e3d00..7f41a76c996 100644 --- a/src/vs/base/common/types.ts +++ b/src/vs/base/common/types.ts @@ -40,16 +40,16 @@ export function isStringArray(value: any): value is string[] { } /** - * @returns whether the provided parameter is a JavaScript Object or not. + * + * @returns whether the provided parameter is of type `object` but **not** + * `null`, an `array`, a `regexp`, nor a `date`. */ export function isObject(obj: any): obj is any { - - // Needed for IE8 - if (typeof obj === 'undefined' || obj === null) { - return false; - } - - return Object.prototype.toString.call(obj) === '[object Object]'; + return typeof obj === 'object' + && obj !== null + && !Array.isArray(obj) + && !(obj instanceof RegExp) + && !(obj instanceof Date); } /** -- GitLab