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)

(cherry picked from commit a19e1f9)
  • Loading branch information
stefanpenner authored and rwjblue committed Aug 13, 2015
1 parent e4f5abb commit c4c5be1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/ember-metal/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ 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) {
Expand Down Expand Up @@ -252,10 +255,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 c4c5be1

Please sign in to comment.