Ignore:
Timestamp:
Feb 6, 2008, 9:33:07 AM (17 years ago)
Author:
Darin Adler
Message:

JavaScriptCore:

Reviewed by Sam.

  • replace calls to put to set up properties with calls to putDirect, to prepare for a future change where put won't take attributes any more, and for a slight performance boost
  • API/JSObjectRef.cpp: (JSObjectMakeConstructor): Use putDirect instead of put.
  • kjs/CommonIdentifiers.h: Removed lastIndex.
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::reset): Use putDirect instead of put.
  • kjs/array_object.cpp: (KJS::arrayProtoFuncConcat): Took out extra call to get length (unused). (KJS::ArrayObjectImp::ArrayObjectImp): Use putDirect instead of put.
  • kjs/error_object.cpp: (KJS::ErrorPrototype::ErrorPrototype): Use putDirect instead of put.
  • kjs/function.cpp: (KJS::Arguments::Arguments): Use putDirect instead of put. (KJS::PrototypeFunction::PrototypeFunction): Use putDirect instead of put.
  • kjs/function_object.cpp: (KJS::FunctionObjectImp::construct): Use putDirect instead of put.
  • kjs/nodes.cpp: (KJS::FuncDeclNode::makeFunction): Use putDirect instead of put. (KJS::FuncExprNode::evaluate): Use putDirect instead of put.
  • kjs/regexp_object.cpp: (KJS::regExpProtoFuncCompile): Use setLastIndex instead of put(lastIndex). (KJS::RegExpImp::match): Get and set lastIndex by using m_lastIndex instead of calling get and put.
  • kjs/regexp_object.h: (KJS::RegExpImp::setLastIndex): Added.
  • kjs/string_object.cpp: (KJS::stringProtoFuncMatch): Use setLastIndex instead of put(lastIndex).

WebCore:

Reviewed by Sam.

  • replace calls to put to set up properties with calls to putDirect, to prepare for a future change where put won't take attributes any more, and for a slight performance boost
  • bindings/js/JSAudioConstructor.cpp: (WebCore::JSAudioConstructor::JSAudioConstructor): Use putDirect instead of put.
  • bindings/js/JSEventTargetBase.h: (WebCore::JSEventTargetPrototype::self): Ditto.
  • bindings/js/JSHTMLOptionElementConstructor.cpp: (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto.
  • bindings/js/JSSQLResultSetRowListCustom.cpp: (WebCore::JSSQLResultSetRowList::item): Ditto.
File:
1 edited

Legend:

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

    r29817 r30040  
    103103
    104104    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    105     for (unsigned int k = 0; k < length; k++) {
     105    for (unsigned k = 0; k < length; k++) {
    106106        if (k >= 1)
    107107            str += separator;
     
    145145
    146146    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    147     for (unsigned int k = 0; k < length; k++) {
     147    for (unsigned k = 0; k < length; k++) {
    148148        if (k >= 1)
    149149            str += separator;
     
    192192
    193193    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    194     for (unsigned int k = 0; k < length; k++) {
     194    for (unsigned k = 0; k < length; k++) {
    195195        if (k >= 1)
    196196            str += separator;
     
    227227    List::const_iterator it = args.begin();
    228228    List::const_iterator end = args.end();
    229     unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    230229    while (1) {
    231230        if (curArg->isObject() && curObj->inherits(&ArrayInstance::info)) {
    232             unsigned int k = 0;
     231            unsigned k = 0;
    233232            // Older versions tried to optimize out getting the length of thisObj
    234233            // by checking for n != 0, but that doesn't work if thisObj is an empty array.
    235             length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
     234            unsigned length = curObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    236235            while (k < length) {
    237236                if (JSValue* v = getProperty(exec, curObj, k))
     
    271270{
    272271    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    273     for (unsigned int n = 0; n < args.size(); n++)
     272    for (unsigned n = 0; n < args.size(); n++)
    274273        thisObj->put(exec, length + n, args[n]);
    275274    length += args.size();
     
    281280{
    282281    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    283     unsigned int middle = length / 2;
    284 
    285     for (unsigned int k = 0; k < middle; k++) {
     282    unsigned middle = length / 2;
     283
     284    for (unsigned k = 0; k < middle; k++) {
    286285        unsigned lk1 = length - k - 1;
    287286        JSValue* obj2 = getProperty(exec, thisObj, lk1);
     
    311310    } else {
    312311        result = thisObj->get(exec, 0);
    313         for (unsigned int k = 1; k < length; k++) {
     312        for (unsigned k = 1; k < length; k++) {
    314313            if (JSValue* obj = getProperty(exec, thisObj, k))
    315314                thisObj->put(exec, k - 1, obj);
     
    392391    // "Min" sort. Not the fastest, but definitely less code than heapsort
    393392    // or quicksort, and much less swapping than bubblesort/insertionsort.
    394     for (unsigned int i = 0 ; i < length - 1 ; ++i) {
     393    for (unsigned i = 0 ; i < length - 1 ; ++i) {
    395394        JSValue* iObj = thisObj->get(exec, i);
    396         unsigned int themin = i;
     395        unsigned themin = i;
    397396        JSValue* minObj = iObj;
    398         for (unsigned int j = i + 1 ; j < length ; ++j) {
     397        for (unsigned j = i + 1 ; j < length ; ++j) {
    399398            JSValue* jObj = thisObj->get(exec, j);
    400399            double compareResult;
     
    439438        begin = std::min<int>(begin, length);
    440439
    441     unsigned int deleteCount;
     440    unsigned deleteCount;
    442441    if (args.size() > 1)
    443442        deleteCount = std::min<int>(std::max<int>(args[1]->toUInt32(exec), 0), length - begin);
     
    445444        deleteCount = length - begin;
    446445
    447     for (unsigned int k = 0; k < deleteCount; k++) {
     446    for (unsigned k = 0; k < deleteCount; k++) {
    448447        if (JSValue* v = getProperty(exec, thisObj, k + begin))
    449448            resObj->put(exec, k, v);
     
    451450    resObj->put(exec, exec->propertyNames().length, jsNumber(deleteCount), DontEnum | DontDelete);
    452451
    453     unsigned int additionalArgs = std::max<int>(args.size() - 2, 0);
     452    unsigned additionalArgs = std::max<int>(args.size() - 2, 0);
    454453    if (additionalArgs != deleteCount) {
    455454        if (additionalArgs < deleteCount) {
    456             for (unsigned int k = begin; k < length - deleteCount; ++k) {
     455            for (unsigned k = begin; k < length - deleteCount; ++k) {
    457456                if (JSValue* v = getProperty(exec, thisObj, k + deleteCount))
    458457                    thisObj->put(exec, k + additionalArgs, v);
     
    460459                    thisObj->deleteProperty(exec, k + additionalArgs);
    461460            }
    462             for (unsigned int k = length ; k > length - deleteCount + additionalArgs; --k)
     461            for (unsigned k = length ; k > length - deleteCount + additionalArgs; --k)
    463462                thisObj->deleteProperty(exec, k - 1);
    464463        } else {
    465             for (unsigned int k = length - deleteCount; (int)k > begin; --k) {
     464            for (unsigned k = length - deleteCount; (int)k > begin; --k) {
    466465                if (JSValue* obj = getProperty(exec, thisObj, k + deleteCount - 1))
    467466                    thisObj->put(exec, k + additionalArgs - 1, obj);
     
    471470        }
    472471    }
    473     for (unsigned int k = 0; k < additionalArgs; ++k)
     472    for (unsigned k = 0; k < additionalArgs; ++k)
    474473        thisObj->put(exec, k + begin, args[k + 2]);
    475474
     
    482481    // 15.4.4.13
    483482    unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec);
    484     unsigned int nrArgs = args.size();
    485     for (unsigned int k = length; k > 0; --k) {
     483    unsigned nrArgs = args.size();
     484    for (unsigned k = length; k > 0; --k) {
    486485        if (JSValue* v = getProperty(exec, thisObj, k - 1))
    487486            thisObj->put(exec, k + nrArgs-1, v);
     
    489488            thisObj->deleteProperty(exec, k + nrArgs-1);
    490489    }
    491     for (unsigned int k = 0; k < nrArgs; ++k)
     490    for (unsigned k = 0; k < nrArgs; ++k)
    492491        thisObj->put(exec, k, args[k]);
    493492    JSValue* result = jsNumber(length + nrArgs);
     
    725724{
    726725    // ECMA 15.4.3.1 Array.prototype
    727     put(exec, exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
     726    putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
    728727
    729728    // no. of arguments for constructor
    730     put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
     729    putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    731730}
    732731
Note: See TracChangeset for help on using the changeset viewer.