benchmarks/scenarios/ember.js
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)';
    }

    if (obj === null) {
      return '(null)';
    }

    var ret;
    var type = typeof obj;

    // Don't allow prototype changes to String etc. to change the guidFor
    switch (type) {
      case 'number':
        ret = numberCache[obj];

        if (!ret) {
          ret = numberCache[obj] = 'nu' + obj;
        }

        return ret;

      case 'string':
        ret = stringCache[obj];

        if (!ret) {
          ret = stringCache[obj] = 'st' + uuid();
        }

        return ret;

      case 'boolean':
        return obj ? '(true)' : '(false)';

      default:
        if (obj === Object) {
          return '(Object)';
        }

        if (obj === Array) {
          return '(Array)';
        }

        ret = GUID_PREFIX + uuid();

        if (obj[GUID_KEY] === null) {
          obj[GUID_KEY] = ret;
        } else {
          GUID_DESC.value = ret;

          if (obj.__defineNonEnumerable) {
            obj.__defineNonEnumerable(GUID_KEY_PROPERTY);
          } else {
            Object.defineProperty(obj, GUID_KEY, GUID_DESC);
          }
        }
        return ret;
    }
  }
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)';
    }

    if (obj === null) {
      return '(null)';
    }

    var ret;
    var type = typeof obj;

    // Don't allow prototype changes to String etc. to change the guidFor
    switch (type) {
      case 'number':
        ret = numberCache[obj];

        if (!ret) {
          ret = numberCache[obj] = 'nu' + obj;
        }

        return ret;

      case 'string':
        ret = stringCache[obj];

        if (!ret) {
          ret = stringCache[obj] = 'st' + uuid();
        }

        return ret;

      case 'boolean':
        return obj ? '(true)' : '(false)';

      default:
        if (obj === Object) {
          return '(Object)';
        }

        if (obj === Array) {
          return '(Array)';
        }

        ret = GUID_PREFIX + uuid();

        if (obj[GUID_KEY] === null) {
          obj[GUID_KEY] = ret;
        } else {
          GUID_DESC.value = ret;

          if (obj.__defineNonEnumerable) {
            obj.__defineNonEnumerable(GUID_KEY_PROPERTY);
          } else {
            Object.defineProperty(obj, GUID_KEY, GUID_DESC);
          }
        }
        return ret;
    }
  }
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)' ; } if ( obj === null ) { return '(null)' ; } var ret ; var type = typeof obj ; // Don't allow prototype changes to String etc. to change the guidFor switch ( type ) { case 'number' : ret = numberCache [ obj ] ; if ( ! ret ) { ret = numberCache [ obj ] = 'nu' + obj ; } return ret ; case 'string' : ret = stringCache [ obj ] ; if ( ! ret ) { ret = stringCache [ obj ] = 'st' + uuid ( ) ; } return ret ; case 'boolean' : return obj ? '(true)' : '(false)' ; default : if ( obj === Object ) { return '(Object)' ; } if ( obj === Array ) { return '(Array)' ; } ret = GUID_PREFIX + uuid ( ) ; if ( obj [ GUID_KEY ] === null ) { obj [ GUID_KEY ] = ret ; } else { GUID_DESC . value = ret ; if ( obj . __defineNonEnumerable ) { obj . __defineNonEnumerable ( GUID_KEY_PROPERTY ) ; } else { Object . defineProperty ( obj , GUID_KEY , GUID_DESC ) ; } } return ret ; } }
Returns a unique id for the object. If the object does not yet have a guid,
one will be assigned to it. You can call this on any object,
`Ember.Object`-based or not, but be aware that it will add a `_guid`
property.

You can also use this method on DOM Element objects.

@public
@method guidFor
@for Ember
@param {Object} obj any object, string, number, Element, or primitive
@return {String} the unique guid for this instance.
Returns a unique id for the object . If the object does not yet have a guid one will be assigned to it . You can call this on any object Ember . Object - based or not but be aware that it will add a _guid property .