Ignore:
Timestamp:
Jun 13, 2007, 9:58:04 PM (18 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Mark Rowe.

Test: fast/js/sort-large-array.html

  • kjs/array_instance.h: Replaced pushUndefinedObjectsToEnd with compactForSorting, and removed ExecState parameters.
  • kjs/array_object.cpp: (ArrayInstance::sort): Changed to call compactForSorting. (ArrayInstance::compactForSorting): Do the get and delete of the properties directly on the property map instead of using public calls from JSObject. The public calls would just read the undefined values from the compacted sort results array!

LayoutTests:

Reviewed by Mark Rowe.

  • fast/js/resources/sort-large-array.js: Added.
  • fast/js/sort-large-array-expected.txt: Added.
  • fast/js/sort-large-array.html: Added.
File:
1 edited

Legend:

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

    r21029 r23521  
    33 *  This file is part of the KDE libraries
    44 *  Copyright (C) 1999-2000 Harri Porten ([email protected])
    5  *  Copyright (C) 2003 Apple Computer, Inc.
     5 *  Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
    66 *  Copyright (C) 2003 Peter Kelly ([email protected])
    77 *  Copyright (C) 2006 Alexey Proskuryakov ([email protected])
     
    331331void ArrayInstance::sort(ExecState* exec)
    332332{
    333     size_t lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
     333    size_t lengthNotIncludingUndefined = compactForSorting();
    334334     
    335335    ExecState* oldExec = execForCompareByStringForQSort;
     
    398398void ArrayInstance::sort(ExecState* exec, JSObject* compareFunction)
    399399{
    400     size_t lengthNotIncludingUndefined = pushUndefinedObjectsToEnd(exec);
     400    size_t lengthNotIncludingUndefined = compactForSorting();
    401401
    402402    CompareWithCompareFunctionArguments* oldArgs = compareWithCompareFunctionArguments;
     
    423423}
    424424
    425 unsigned ArrayInstance::pushUndefinedObjectsToEnd(ExecState *exec)
     425unsigned ArrayInstance::compactForSorting()
    426426{
    427427    JSValue *undefined = jsUndefined();
     
    448448    for (PropertyNameArrayIterator it = sparseProperties.begin(); it != end; ++it) {
    449449        Identifier name = *it;
    450         storage[o] = get(exec, name);
    451         JSObject::deleteProperty(exec, name);
     450        storage[o] = getDirect(name);
     451        _prop.remove(name);
    452452        o++;
    453453    }
Note: See TracChangeset for help on using the changeset viewer.