summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-12 20:10:57 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-12 20:32:24 (GMT)
commit88c6dc6ec7f73de279703b30874b30511901854b (patch)
tree15d1b87a2f10bbaf9d8e08a8bee75de9ed71afe6
parent18e548c3f705fa6b4ebfac80fe79fe49dac54a0a (diff)
downloadQt-88c6dc6ec7f73de279703b30874b30511901854b.zip
Qt-88c6dc6ec7f73de279703b30874b30511901854b.tar.gz
Qt-88c6dc6ec7f73de279703b30874b30511901854b.tar.bz2
Make simple function getters inline
-rw-r--r--src/script/api/qscriptengine.cpp14
-rw-r--r--src/script/api/qscriptengine_p.h4
-rw-r--r--src/script/api/qscriptvalue.cpp5
-rw-r--r--src/script/api/qscriptvalue_p.h2
-rw-r--r--tests/benchmarks/qscriptengine/tst_qscriptengine.cpp17
5 files changed, 20 insertions, 22 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9f9242c..e8ea222 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -1363,20 +1363,6 @@ void QScriptEnginePrivate::detachAllRegisteredScriptValues()
}
}
-QScriptEnginePrivate *QScriptEnginePrivate::get(QScriptEngine *q)
-{
- if (!q)
- return 0;
- return q->d_func();
-}
-
-QScriptEngine *QScriptEnginePrivate::get(QScriptEnginePrivate *d)
-{
- if (!d)
- return 0;
- return d->q_func();
-}
-
#ifdef QT_NO_QOBJECT
QScriptEngine::QScriptEngine()
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index 572f361..86c7616 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -113,8 +113,8 @@ public:
QScriptEnginePrivate();
virtual ~QScriptEnginePrivate();
- static QScriptEnginePrivate *get(QScriptEngine*);
- static QScriptEngine *get(QScriptEnginePrivate*);
+ static QScriptEnginePrivate *get(QScriptEngine *q) { return q ? q->d_func() : 0; }
+ static QScriptEngine *get(QScriptEnginePrivate *d) { return d ? d->q_func() : 0; }
static bool convert(const QScriptValue &value,
int type, void *ptr,
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp
index aa0e8cb..b02802c 100644
--- a/src/script/api/qscriptvalue.cpp
+++ b/src/script/api/qscriptvalue.cpp
@@ -348,11 +348,6 @@ bool QScriptValuePrivate::isJSC() const
return (type == JSC);
}
-QScriptValuePrivate *QScriptValuePrivate::get(const QScriptValue &q)
-{
- return q.d_ptr;
-}
-
QScriptValue QScriptValuePrivate::property(const QString &name, int resolveMode) const
{
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(engine);
diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h
index 3359cba..b19435c 100644
--- a/src/script/api/qscriptvalue_p.h
+++ b/src/script/api/qscriptvalue_p.h
@@ -130,7 +130,7 @@ public:
QVariant &variantValue() const;
void setVariantValue(const QVariant &value);
- static QScriptValuePrivate *get(const QScriptValue &q);
+ static QScriptValuePrivate *get(const QScriptValue &q) { return q.d_ptr; }
QScriptValue property(const JSC::Identifier &id, int resolveMode) const;
QScriptValue property(const QString &, int resolveMode) const;
diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
index 81dedfa..515285d 100644
--- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp
@@ -69,6 +69,7 @@ private slots:
void pushAndPopContext();
void toStringHandle();
void castValueToQreal();
+ void nativeCall();
};
tst_QScriptEngine::tst_QScriptEngine()
@@ -225,5 +226,21 @@ void tst_QScriptEngine::castValueToQreal()
}
}
+static QScriptValue native_function(QScriptContext *, QScriptEngine *)
+{
+ return 42;
+}
+
+void tst_QScriptEngine::nativeCall()
+{
+ QScriptEngine eng;
+ eng.globalObject().setProperty("fun", eng.newFunction(native_function));
+ QBENCHMARK{
+ eng.evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n"
+ " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }");
+ }
+}
+
+
QTEST_MAIN(tst_QScriptEngine)
#include "tst_qscriptengine.moc"