diff options
-rw-r--r-- | src/qml/jsruntime/qv4arraydata.cpp | 41 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sparsearray.cpp | 26 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sparsearray_p.h | 19 |
3 files changed, 43 insertions, 43 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 9c6ff94583..63fe650cd5 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -630,6 +630,47 @@ Property *ArrayData::insert(Object *o, uint index, bool isAccessor) return reinterpret_cast<Property *>(o->arrayData->data + n->value); } + +class ArrayElementLessThan +{ +public: + inline ArrayElementLessThan(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn) + : m_context(context), thisObject(thisObject), m_comparefn(comparefn) {} + + bool operator()(const SafeValue &v1, const SafeValue &v2) const; + +private: + ExecutionContext *m_context; + ObjectRef thisObject; + const ValueRef m_comparefn; +}; + + +bool ArrayElementLessThan::operator()(const SafeValue &v1, const SafeValue &v2) const +{ + Scope scope(m_context); + + if (v1.isUndefined() || v1.isEmpty()) + return false; + if (v2.isUndefined() || v2.isEmpty()) + return true; + ScopedObject o(scope, m_comparefn); + if (o) { + Scope scope(o->engine()); + ScopedValue result(scope); + ScopedCallData callData(scope, 2); + callData->thisObject = Primitive::undefinedValue(); + callData->args[0] = v1; + callData->args[1] = v2; + result = __qmljs_call_value(m_context, m_comparefn, callData); + + return result->toNumber() < 0; + } + ScopedString p1s(scope, v1.toString(m_context)); + ScopedString p2s(scope, v2.toString(m_context)); + return p1s->toQString() < p2s->toQString(); +} + void ArrayData::sort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint len) { if (!len) diff --git a/src/qml/jsruntime/qv4sparsearray.cpp b/src/qml/jsruntime/qv4sparsearray.cpp index 7169f5c20e..ffd1adf98b 100644 --- a/src/qml/jsruntime/qv4sparsearray.cpp +++ b/src/qml/jsruntime/qv4sparsearray.cpp @@ -53,32 +53,6 @@ using namespace QV4; -bool ArrayElementLessThan::operator()(const SafeValue &v1, const SafeValue &v2) const -{ - Scope scope(m_context); - - if (v1.isUndefined() || v1.isEmpty()) - return false; - if (v2.isUndefined() || v2.isEmpty()) - return true; - ScopedObject o(scope, m_comparefn); - if (o) { - Scope scope(o->engine()); - ScopedValue result(scope); - ScopedCallData callData(scope, 2); - callData->thisObject = Primitive::undefinedValue(); - callData->args[0] = v1; - callData->args[1] = v2; - result = __qmljs_call_value(m_context, m_comparefn, callData); - - return result->toNumber() < 0; - } - ScopedString p1s(scope, v1.toString(m_context)); - ScopedString p2s(scope, v2.toString(m_context)); - return p1s->toQString() < p2s->toQString(); -} - - const SparseArrayNode *SparseArrayNode::nextNode() const { const SparseArrayNode *n = this; diff --git a/src/qml/jsruntime/qv4sparsearray_p.h b/src/qml/jsruntime/qv4sparsearray_p.h index 648fc9ac7d..0bcbc805f3 100644 --- a/src/qml/jsruntime/qv4sparsearray_p.h +++ b/src/qml/jsruntime/qv4sparsearray_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QV4ARRAY_H -#define QV4ARRAY_H +#ifndef QV4SPARSEARRAY_H +#define QV4SPARSEARRAY_H #include "qv4global_p.h" #include <QtCore/qmap.h> @@ -62,21 +62,6 @@ namespace QV4 { struct SparseArray; -class ArrayElementLessThan -{ -public: - inline ArrayElementLessThan(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn) - : m_context(context), thisObject(thisObject), m_comparefn(comparefn) {} - - bool operator()(const SafeValue &v1, const SafeValue &v2) const; - -private: - ExecutionContext *m_context; - ObjectRef thisObject; - const ValueRef m_comparefn; -}; - - struct SparseArrayNode { quintptr p; |