diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-17 17:48:34 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-03-12 17:29:36 +0000 |
commit | 6417bbde8565e0be2d049426b71e6fda538e4440 (patch) | |
tree | 8e60f1edf1f8e0f07fc1e6eed23e44389bdb9a67 /src/plugins/platforms/android/qandroidinputcontext.cpp | |
parent | 8c0ae00dd603bfe5aa99b5b2db8c1ffdaa6cd45e (diff) |
QtBase (remainder): use printf-style qWarning/qDebug where possible (I)
The printf-style version of QDebug expands to a lot less code than the
std::ostream-style version. Of course, you pay in type safety (but
compilers warn about it these days), you cannot stream complex Qt
types and streaming QStrings is awkward, but in many cases you
actually improve on readability.
But the main reason is that something that's not supposed to be
executed under normal operation has no business bloating executable
code size.
This is not an attempt at converting all qWarnings() to printf-style,
only the low-hanging fruit.
In this first part, replace
qWarning() << ""
with
qWarning("...").
Had to fix broken qImDebug() definition. Instead of defining it as
a nullary macro in the QT_NO_DEBUG case and as a variadic macro in
the other, define it in both cases, as is customary, as a non-function
macro so that overload selection works without requiring variadic
macro support of the compiler.
Saves e.g. ~250b in text size in QtPrintSupport on optimized GCC 5.3
AMD64 builds.
Change-Id: Ie30fe2f7942115d5dbf99fff1750ae0d477c379f
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/android/qandroidinputcontext.cpp')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index ddf806a68f..eb9e95508c 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -78,7 +78,7 @@ static jboolean beginBatchEdit(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ BEGINBATCH"; + qDebug("@@@ BEGINBATCH"); #endif return m_androidInputContext->beginBatchEdit(); @@ -92,7 +92,7 @@ static jboolean endBatchEdit(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ ENDBATCH"; + qDebug("@@@ ENDBATCH"); #endif return m_androidInputContext->endBatchEdit(); @@ -134,7 +134,7 @@ static jboolean finishComposingText(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ FINISH"; + qDebug("@@@ FINISH"); #endif return m_androidInputContext->finishComposingText(); } @@ -256,7 +256,7 @@ static jboolean selectAll(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ SELALL"; + qDebug("@@@ SELALL"); #endif return m_androidInputContext->selectAll(); } @@ -267,7 +267,7 @@ static jboolean cut(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->cut(); } @@ -278,7 +278,7 @@ static jboolean copy(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->copy(); } @@ -289,7 +289,7 @@ static jboolean copyURL(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->copyURL(); } @@ -300,7 +300,7 @@ static jboolean paste(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@"; + qDebug("@@@"); #endif return m_androidInputContext->paste(); } @@ -311,7 +311,7 @@ static jboolean updateCursorPosition(JNIEnv */*env*/, jobject /*thiz*/) return JNI_FALSE; #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ UPDATECURSORPOS"; + qDebug("@@@ UPDATECURSORPOS"); #endif m_androidInputContext->updateCursorPosition(); return true; @@ -371,43 +371,43 @@ QAndroidInputContext::QAndroidInputContext() m_extractedTextClass = static_cast<jclass>(env->NewGlobalRef(clazz)); m_classConstructorMethodID = env->GetMethodID(m_extractedTextClass, "<init>", "()V"); if (Q_UNLIKELY(!m_classConstructorMethodID)) { - qCritical() << "GetMethodID failed"; + qCritical("GetMethodID failed"); return; } m_partialEndOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialEndOffset", "I"); if (Q_UNLIKELY(!m_partialEndOffsetFieldID)) { - qCritical() << "Can't find field partialEndOffset"; + qCritical("Can't find field partialEndOffset"); return; } m_partialStartOffsetFieldID = env->GetFieldID(m_extractedTextClass, "partialStartOffset", "I"); if (Q_UNLIKELY(!m_partialStartOffsetFieldID)) { - qCritical() << "Can't find field partialStartOffset"; + qCritical("Can't find field partialStartOffset"); return; } m_selectionEndFieldID = env->GetFieldID(m_extractedTextClass, "selectionEnd", "I"); if (Q_UNLIKELY(!m_selectionEndFieldID)) { - qCritical() << "Can't find field selectionEnd"; + qCritical("Can't find field selectionEnd"); return; } m_selectionStartFieldID = env->GetFieldID(m_extractedTextClass, "selectionStart", "I"); if (Q_UNLIKELY(!m_selectionStartFieldID)) { - qCritical() << "Can't find field selectionStart"; + qCritical("Can't find field selectionStart"); return; } m_startOffsetFieldID = env->GetFieldID(m_extractedTextClass, "startOffset", "I"); if (Q_UNLIKELY(!m_startOffsetFieldID)) { - qCritical() << "Can't find field startOffset"; + qCritical("Can't find field startOffset"); return; } m_textFieldID = env->GetFieldID(m_extractedTextClass, "text", "Ljava/lang/String;"); if (Q_UNLIKELY(!m_textFieldID)) { - qCritical() << "Can't find field text"; + qCritical("Can't find field text"); return; } qRegisterMetaType<QInputMethodEvent *>("QInputMethodEvent*"); |