diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-01-14 14:42:21 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-15 11:43:08 +0100 |
commit | 6b902b958a0923cb465270b3ee57ce0de6e4c3e2 (patch) | |
tree | 45bc8685ac7c76fae4d7b6cb8a3dd8c7b7bb561e | |
parent | 079605f6941f7fc04937befe19d678515f7cbc42 (diff) | |
download | qtlocation-6b902b958a0923cb465270b3ee57ce0de6e4c3e2.tar.gz |
Don't use QString if not required (Performance improvement)
Change-Id: I80cf4dcd98c45169b31ee1659122020ce27b29ea
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/plugins/position/android/src/jnipositioning.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp index 3f5d1cf9..6b49b9fe 100644 --- a/src/plugins/position/android/src/jnipositioning.cpp +++ b/src/plugins/position/android/src/jnipositioning.cpp @@ -173,7 +173,7 @@ namespace AndroidPositioning { } //caching originally taken from corelib/kernel/qjni.cpp - typedef QHash<QString, jmethodID> JMethodIDHash; + typedef QHash<QByteArray, jmethodID> JMethodIDHash; Q_GLOBAL_STATIC(JMethodIDHash, cachedMethodID) static jmethodID getCachedMethodID(JNIEnv *env, @@ -182,8 +182,12 @@ namespace AndroidPositioning { const char *sig) { jmethodID id = 0; - const QString key = QStringLiteral("%1%2").arg(QLatin1String(name)).arg(QLatin1String(sig)); - QHash<QString, jmethodID>::iterator it = cachedMethodID->find(key); + int offset_name = qstrlen(name); + int offset_signal = qstrlen(sig); + QByteArray key(offset_name + offset_signal, Qt::Uninitialized); + memcpy(key.data(), name, offset_name); + memcpy(key.data()+offset_name, sig, offset_signal); + QHash<QByteArray, jmethodID>::iterator it = cachedMethodID->find(key); if (it == cachedMethodID->end()) { id = env->GetMethodID(clazz, name, sig); if (env->ExceptionCheck()) { |