Changeset 1272 in webkit for trunk/JavaScriptCore/kjs/nodes.cpp


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/nodes.cpp

    r1024 r1272  
    31363136  KJS_CHECKEXCEPTION
    31373137
     3138#ifdef APPLE_CHANGES
     3139  Completion c1 = element->execute(exec);
     3140  KJS_CHECKEXCEPTION;
     3141  if (c1.complType() != Normal)
     3142    return c1;
     3143 
     3144  for (SourceElementsNode *node = elements; node; node = node->elements) {
     3145    Completion c2 = node->element->execute(exec);
     3146    if (c2.complType() != Normal)
     3147      return c2;
     3148    // The spec says to return c2 here, but it seems that mozilla returns c1 if
     3149    // c2 doesn't have a value
     3150    if (!c2.value().isNull())
     3151      c1 = c2;
     3152  }
     3153 
     3154  return c1;
     3155#else
    31383156  if (!elements)
    31393157    return element->execute(exec);
     
    31533171  else
    31543172    return c2;
     3173#endif
    31553174}
    31563175
     
    31583177void SourceElementsNode::processFuncDecl(ExecState *exec)
    31593178{
     3179#ifdef APPLE_CHANGES
     3180  for (SourceElementsNode *node = this; node; node = node->elements) {
     3181    node->element->processFuncDecl(exec);
     3182  }
     3183#else
    31603184  if (elements)
    31613185    elements->processFuncDecl(exec);
    31623186
    31633187  element->processFuncDecl(exec);
     3188#endif
    31643189}
    31653190
    31663191void SourceElementsNode::processVarDecls(ExecState *exec)
    31673192{
     3193#ifdef APPLE_CHANGES
     3194  for (SourceElementsNode *node = this; node; node = node->elements) {
     3195    node->element->processVarDecls(exec);
     3196  }
     3197#else
    31683198  if (elements)
    31693199    elements->processVarDecls(exec);
    31703200
    31713201  element->processVarDecls(exec);
     3202#endif
    31723203}
    31733204
Note: See TracChangeset for help on using the changeset viewer.