From a19e1f986ff4bc78de5bbb853ba84e632590107e Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Tue, 11 Aug 2015 23:51:51 -0700 Subject: [PATCH] [BUGFIX release] improve performance of guidFor when reading an existing guid * This made OrderedSet#add 2x -> 3x faster (helps our ember-data friends) * This appears to have made OrderedSet#add faster then V8 native Set#add (for now) --- packages/ember-metal/lib/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ember-metal/lib/utils.js b/packages/ember-metal/lib/utils.js index 86f6a17095c..2cdeffec2d5 100644 --- a/packages/ember-metal/lib/utils.js +++ b/packages/ember-metal/lib/utils.js @@ -201,6 +201,10 @@ export function generateGuid(obj, prefix) { @return {String} the unique guid for this instance. */ export function guidFor(obj) { + if (obj && obj[GUID_KEY]) { + return obj[GUID_KEY]; + } + // special cases where we don't want to add a key to object if (obj === undefined) { return '(undefined)'; @@ -237,10 +241,6 @@ export function guidFor(obj) { return obj ? '(true)' : '(false)'; default: - if (obj[GUID_KEY]) { - return obj[GUID_KEY]; - } - if (obj === Object) { return '(Object)'; }