Changeset 34964 in webkit for trunk/JavaScriptCore/kjs/JSString.h


Ignore:
Timestamp:
Jul 2, 2008, 5:47:00 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-02 Geoffrey Garen <[email protected]>

Reviewed by Oliver Hunt.

Optimized a[n] get for cases where a is an array or a string, and a[n]
put for cases where a is an array.


SunSpider says 9.0% faster.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSString.h

    r34921 r34964  
    4343    bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    4444    bool getStringPropertySlot(unsigned propertyName, PropertySlot&);
     45
     46    bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); }
     47    JSValue* getIndex(ExecState* exec, unsigned i)
     48    {
     49        ASSERT(canGetIndex(i));
     50        return new (exec) JSString(m_value.substr(i, 1));
     51    }
    4552
    4653  private:
Note: See TracChangeset for help on using the changeset viewer.