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

    r12317 r12435  
    3030#include "dtoa.h"
    3131
     32#include <kxmlcore/Vector.h>
     33
    3234#include "number_object.lut.h"
    3335
    3436#include <assert.h>
    3537#include <math.h>
     38
    3639using namespace KJS;
    3740
     
    9598        str += UString("0");
    9699    } else {
    97         char *buf;
     100        Vector<char, 1024> buf(decimalPoint + 1);
    98101       
    99102        if (length <= decimalPoint) {
    100             buf = (char*)fastMalloc(decimalPoint+1);
    101             strcpy(buf,result);
    102             memset(buf+length,'0',decimalPoint-length);
    103         } else {
    104             buf = (char*)fastMalloc(decimalPoint+1);
    105             strncpy(buf,result,decimalPoint);
    106         }
     103            strcpy(buf, result);
     104            memset(buf + length, '0', decimalPoint - length);
     105        } else
     106            strncpy(buf, result, decimalPoint);
    107107       
    108108        buf[decimalPoint] = '\0';
    109109        str += UString(buf);
    110         fastFree(buf);
    111110    }
    112111   
     
    118117static UString char_sequence(char c, int count)
    119118{
    120     char *buf = (char*)fastMalloc(count+1);
    121     memset(buf,c,count);
     119    Vector<char, 2048> buf(count + 1, c);
    122120    buf[count] = '\0';
    123     UString s(buf);
    124     fastFree(buf);
    125     return s;
     121
     122    return UString(buf);
    126123}
    127124
Note: See TracChangeset for help on using the changeset viewer.