diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-07 10:56:50 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-07 16:16:07 (GMT) |
commit | 2dd5facac01df4a90fbf9b7ce666704fddaf9e4f (patch) | |
tree | 6e23b75546b991d9433714d7ba439ed50df592b0 /src/script/api | |
parent | df5cdc6d9a22ae11d607e9359a3bb9a80596fdb6 (diff) | |
download | Qt-2dd5facac01df4a90fbf9b7ce666704fddaf9e4f.zip Qt-2dd5facac01df4a90fbf9b7ce666704fddaf9e4f.tar.gz Qt-2dd5facac01df4a90fbf9b7ce666704fddaf9e4f.tar.bz2 |
Inline QScriptValuePrivate operator new and delete
Make allocation faster.
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine_p.h | 16 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 16 | ||||
-rw-r--r-- | src/script/api/qscriptvalue_p.h | 4 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 5f31054..f1fc135 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -468,6 +468,22 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol return property(JSC::Identifier(exec, name), resolveMode); } +inline void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate *engine) +{ + if (engine) + return engine->allocateScriptValuePrivate(size); + return qMalloc(size); +} + +inline void QScriptValuePrivate::operator delete(void *ptr) +{ + QScriptValuePrivate *d = reinterpret_cast<QScriptValuePrivate*>(ptr); + if (d->engine) + d->engine->freeScriptValuePrivate(d); + else + qFree(d); +} + inline void QScriptEnginePrivate::registerScriptString(QScriptStringPrivate *value) { Q_ASSERT(value->type == QScriptStringPrivate::HeapAllocated); diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 92c987c..1c668a9 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -466,22 +466,6 @@ void QScriptValuePrivate::detachFromEngine() engine = 0; } -void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate *engine) -{ - if (engine) - return engine->allocateScriptValuePrivate(size); - return qMalloc(size); -} - -void QScriptValuePrivate::operator delete(void *ptr) -{ - QScriptValuePrivate *d = reinterpret_cast<QScriptValuePrivate*>(ptr); - if (d->engine) - d->engine->freeScriptValuePrivate(d); - else - qFree(d); -} - /*! \internal */ diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 6cbda97..351d616 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -68,8 +68,8 @@ class QScriptValuePrivate { Q_DISABLE_COPY(QScriptValuePrivate); public: - void* operator new(size_t, QScriptEnginePrivate*); - void operator delete(void*); + inline void* operator new(size_t, QScriptEnginePrivate*); + inline void operator delete(void*); enum Type { JavaScriptCore, |