Skip to content

Commit

Permalink
[BUGFIX release] improve performance of guidFor when reading an exist…
Browse files Browse the repository at this point in the history
…ing 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)
  • Loading branch information
stefanpenner committed Aug 12, 2015
1 parent 691fc60 commit a19e1f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ember-metal/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)';
Expand Down Expand Up @@ -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)';
}
Expand Down

0 comments on commit a19e1f9

Please sign in to comment.