diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-11-12 10:16:22 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-11-29 22:59:17 +0000 |
commit | 51089a5742a79467221b5781cb35a8cea023febf (patch) | |
tree | 95f765fa452cdfaa12f986e4d228d9a958c95100 /src/plugins/platforms/android/qandroidinputcontext.cpp | |
parent | 14d189f7875b7def6f9745bfd20527a0fce19a44 (diff) |
Use Q_UNLIKELY for every qFatal()/qCritical()
If, after checking a condition, we issue a qFatal()
or a qCritical(), by definition that check is
unlikely to be true.
Tell the compiler so it can move the error handling
code out of the normal code path to increase the
effective icache size.
Moved conditional code around where possible so that
we could always use Q_UNLIKELY, instead of having to
revert to Q_LIKELY here and there.
In some cases, simplified the expressions newly wrapped
in Q_UNLIKELY as a drive-by.
Change-Id: I67537d62b04bc6977d69254690c5ebbdf98bfd6d
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/plugins/platforms/android/qandroidinputcontext.cpp')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index e3ea048e84..92c0c2cf0f 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -339,7 +339,7 @@ QAndroidInputContext::QAndroidInputContext() : QPlatformInputContext(), m_composingTextStart(-1), m_blockUpdateSelection(false), m_batchEditNestingLevel(0), m_focusObject(0) { jclass clazz = QJNIEnvironmentPrivate::findClass(QtNativeInputConnectionClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtNativeInputConnectionClassName << '\''; @@ -347,7 +347,7 @@ QAndroidInputContext::QAndroidInputContext() } QJNIEnvironmentPrivate env; - if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0) { + if (Q_UNLIKELY(env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) < 0)) { qCritical() << "RegisterNatives failed for '" << QtNativeInputConnectionClassName << '\''; @@ -355,7 +355,7 @@ QAndroidInputContext::QAndroidInputContext() } clazz = QJNIEnvironmentPrivate::findClass(QtExtractedTextClassName); - if (clazz == NULL) { + if (Q_UNLIKELY(!clazz)) { qCritical() << "Native registration unable to find class '" << QtExtractedTextClassName << '\''; @@ -364,43 +364,43 @@ QAndroidInputContext::QAndroidInputContext() m_extractedTextClass = static_cast<jclass>(env->NewGlobalRef(clazz)); m_classConstructorMethodID = env->GetMethodID(m_extractedTextClass, "<init>", "()V"); - if (m_classConstructorMethodID == NULL) { + if (Q_UNLIKELY(!m_classConstructorMethodID)) { qCritical() << "GetMethodID failed"; return; } m_partialEndOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialEndOffset", "I"); - if (m_partialEndOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialEndOffsetFieldID)) { qCritical() << "Can't find field partialEndOffset"; return; } m_partialStartOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialStartOffset", "I"); - if (m_partialStartOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_partialStartOffsetFieldID)) { qCritical() << "Can't find field partialStartOffset"; return; } m_selectionEndFieldID = env->GetFieldID(m_extractedTextClass, "selectionEnd", "I"); - if (m_selectionEndFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionEndFieldID)) { qCritical() << "Can't find field selectionEnd"; return; } m_selectionStartFieldID = env->GetFieldID(m_extractedTextClass, "selectionStart", "I"); - if (m_selectionStartFieldID == NULL) { + if (Q_UNLIKELY(!m_selectionStartFieldID)) { qCritical() << "Can't find field selectionStart"; return; } m_startOffsetFieldID = env->GetFieldID(m_extractedTextClass, "startOffset", "I"); - if (m_startOffsetFieldID == NULL) { + if (Q_UNLIKELY(!m_startOffsetFieldID)) { qCritical() << "Can't find field startOffset"; return; } m_textFieldID = env->GetFieldID(m_extractedTextClass, "text", "Ljava/lang/String;"); - if (m_textFieldID == NULL) { + if (Q_UNLIKELY(!m_textFieldID)) { qCritical() << "Can't find field text"; return; } |