Changeset 1272 in webkit for trunk/JavaScriptCore/kjs/ustring.h


Ignore:
Timestamp:
Jun 4, 2002, 3:33:26 PM (23 years ago)
Author:
darin
Message:

Improve the speed of the JavaScript string append operation by growing
the capacity so we don't need to reallocate the string every time.

Also fix script execution so it doesn't use recursion to advance from
one statement to the next, using iteration instead.

  • Makefile.am: Stop using BUILT_SOURCES to build JavaScriptCore-stamp, because this causes the Project Builder project to build *before* the subdir. Intead, use an all-am rule in a way more similar to all our other directories.
  • kjs/grammar.y: Link the SourceElementsNode in the opposite direction, so we can walk the list and execute each element instead of using recursion to reverse the list.
  • kjs/grammar.cpp: Check in new generated file.
  • kjs/nodes.cpp: (SourceElementsNode::execute): (SourceElementsNode::processFuncDecl): (SourceElementsNode::processVarDecls): Use loops instead of recursion.
  • kjs/ustring.h: Don't initialize all UChar objects to 0. This was wasting a *huge* amount of time.
  • kjs/ustring.cpp: (UString::Rep::create): Add a "capacity" along with the length. (UString::append): Include 50% extra capacity when appending. (UString::operator=): Reuse the buffer if possible rather than always creating a new one.
File:
1 edited

Legend:

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

    r1024 r1272  
    5757   */
    5858  struct UChar {
    59     /**
    60      * Construct a character with value 0.
    61      */
     59#ifdef APPLE_CHANGES
     60    /**
     61     * Construct a character with uninitialized value.   
     62     */
     63#else
     64    /**
     65     * Construct a character with value 0.   
     66     */
     67#endif
    6268    UChar();
    6369    /**
     
    108114  };
    109115
     116#ifdef APPLE_CHANGES
    110117  inline UChar::UChar() : uc(0) { }
     118#else
     119  inline UChar::UChar() { }
     120#endif
    111121  inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { }
    112122  inline UChar::UChar(unsigned short u) : uc(u) { }
     
    210220      UChar *dat;
    211221      int len;
     222#ifdef APPLE_CHANGES
     223      int capacity;
     224#endif
    212225      int rc;
    213226      static Rep null;
     
    232245     */
    233246    UString(const UChar *c, int length);
     247#ifdef APPLE_CHANGES
     248    /**
     249     * If copy is false the string data will be adopted.
     250     * That means that the data will NOT be copied and the pointer will
     251     * be deleted when the UString object is modified or destroyed.
     252     * Behaviour defaults to a deep copy if copy is true.
     253     */
     254#else
    234255    /**
    235256     * If copy is false a shallow copy of the string will be created. That
     
    238259     * Behaviour defaults to a deep copy if copy is true.
    239260     */
     261#endif
    240262    UString(UChar *c, int length, bool copy);
    241263    /**
Note: See TracChangeset for help on using the changeset viewer.