Commit 7a274f51 authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Darin.

        Get rid of static execForCompareByStringForQSort in array_instance.cpp.

        No change on SunSpider, CelticKane or iBench JavaScript.

        * kjs/array_instance.cpp:
        (KJS::ArraySortComparator::ArraySortComparator):
        (KJS::ArraySortComparator::operator()):
        (KJS::ArrayInstance::sort):
        Switch slow case to std::sort, so that ExecState can be passed in a comparator.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 332d3a5a
2008-04-16 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
Get rid of static execForCompareByStringForQSort in array_instance.cpp.
No change on SunSpider, CelticKane or iBench JavaScript.
* kjs/array_instance.cpp:
(KJS::ArraySortComparator::ArraySortComparator):
(KJS::ArraySortComparator::operator()):
(KJS::ArrayInstance::sort):
Switch slow case to std::sort, so that ExecState can be passed in a comparator.
2008-04-16 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Adam Roben.
......
......@@ -435,18 +435,20 @@ static int compareByStringPairForQSort(const void* a, const void* b)
return compare(va->second, vb->second);
}
static ExecState* execForCompareByStringForQSort = 0;
static int compareByStringForQSort(const void* a, const void* b)
{
ExecState* exec = execForCompareByStringForQSort;
class ArraySortComparator {
public:
ArraySortComparator(ExecState* exec) : m_exec(exec) {}
JSValue* va = *static_cast<JSValue* const*>(a);
JSValue* vb = *static_cast<JSValue* const*>(b);
ASSERT(!va->isUndefined());
ASSERT(!vb->isUndefined());
bool operator()(JSValue* va, JSValue* vb)
{
ASSERT(!va->isUndefined());
ASSERT(!vb->isUndefined());
return compare(va->toString(m_exec), vb->toString(m_exec)) < 0;
}
return compare(va->toString(exec), vb->toString(exec));
}
private:
ExecState* m_exec;
};
void ArrayInstance::sort(ExecState* exec)
{
......@@ -478,10 +480,7 @@ void ArrayInstance::sort(ExecState* exec)
return;
}
ExecState* oldExec = execForCompareByStringForQSort;
execForCompareByStringForQSort = exec;
qsort(m_storage->m_vector, lengthNotIncludingUndefined, sizeof(JSValue*), compareByStringForQSort);
execForCompareByStringForQSort = oldExec;
std::sort(m_storage->m_vector, m_storage->m_vector + lengthNotIncludingUndefined, ArraySortComparator(exec));
}
struct CompareWithCompareFunctionArguments {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment