Ignore:
Timestamp:
Jan 28, 2006, 8:12:59 PM (19 years ago)
Author:
mjs
Message:

Reviewed by Dave Hyatt.


  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/internal.cpp: (KJS::Parser::saveNewNode): Apply Vector. (KJS::clearNewNodes): ditto
  • kjs/number_object.cpp: (integer_part_noexp): ditto (char_sequence): ditto
  • kjs/ustring.cpp: (KJS::UString::UTF8String): ditto
  • kxmlcore/HashMap.h: (KXMLCore::deleteAllValues): Tweaked this to only apply to HashMap, other versions are useful for other containers.
  • kxmlcore/Vector.h: Added. Implemented a Vector class, which should be usable for all Array/QVector style purposes, and also as a stack buffer with oversize handling. Also some helper classes to make vector operations as efficient as possible for POD types and for simple non-PODs like RefPtr. (KXMLCore::): (KXMLCore::VectorTypeOperations::destruct): (KXMLCore::VectorTypeOperations::initialize): (KXMLCore::VectorTypeOperations::move): (KXMLCore::VectorTypeOperations::uninitializedCopy): (KXMLCore::VectorTypeOperations::uninitializedFill): (KXMLCore::VectorBuffer::VectorBuffer): (KXMLCore::VectorBuffer::~VectorBuffer): (KXMLCore::VectorBuffer::deallocateBuffer): (KXMLCore::VectorBuffer::inlineBuffer): (KXMLCore::Vector::Vector): (KXMLCore::Vector::~Vector): (KXMLCore::Vector::size): (KXMLCore::Vector::capacity): (KXMLCore::Vector::isEmpty): (KXMLCore::Vector::at): (KXMLCore::Vector::operator[]): (KXMLCore::Vector::data): (KXMLCore::Vector::operator T*): (KXMLCore::Vector::operator const T*): (KXMLCore::Vector::begin): (KXMLCore::Vector::end): (KXMLCore::Vector::clear): (KXMLCore::Vector::fill): (KXMLCore::Vector::operator=): (KXMLCore::::Vector): (KXMLCore::::operator): (KXMLCore::::fill): (KXMLCore::::expandCapacity): (KXMLCore::::resize): (KXMLCore::::reserveCapacity): (KXMLCore::::append): (KXMLCore::deleteAllValues):
  • kxmlcore/VectorTraits.h: Added. (KXMLCore::VectorTraits): Traits to enable making Vector efficient for simple types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r12352 r12435  
    4444#include <assert.h>
    4545#include <kxmlcore/HashMap.h>
     46#include <kxmlcore/Vector.h>
    4647#include <math.h>
    4748#include <stdio.h>
     
    353354int Parser::sid = 0;
    354355
    355 const int initialCapacity = 64;
    356 const int growthFactor = 2;
    357 
    358 static int numNewNodes;
    359 static int newNodesCapacity;
    360 static Node **newNodes;
     356static Vector<RefPtr<Node> >* newNodes;
    361357
    362358void Parser::saveNewNode(Node *node)
    363359{
    364   if (numNewNodes == newNodesCapacity) {
    365     newNodesCapacity = (newNodesCapacity == 0) ? initialCapacity : newNodesCapacity * growthFactor;
    366     newNodes = (Node **)fastRealloc(newNodes, sizeof(Node *) * newNodesCapacity);
    367   }
    368 
    369   newNodes[numNewNodes++] = node;
     360    if (!newNodes)
     361        newNodes = new Vector<RefPtr<Node> >;
     362
     363    newNodes->append(node);
    370364}
    371365
    372366static void clearNewNodes()
    373367{
    374   for (int i = 0; i < numNewNodes; i++) {
    375     if (newNodes[i]->refcount() == 0)
    376       delete newNodes[i];
    377   }
    378   fastFree(newNodes);
    379   newNodes = 0;
    380   numNewNodes = 0;
    381   newNodesCapacity = 0;
     368    delete newNodes;
     369    newNodes = 0;
    382370}
    383371
Note: See TracChangeset for help on using the changeset viewer.