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/ios | |
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/ios')
-rw-r--r-- | src/plugins/platforms/ios/qioseventdispatcher.mm | 4 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosintegration.mm | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 0e9f176487..e1c6071c38 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -129,7 +129,7 @@ namespace // Which we verify, just in case struct rlimit stackLimit = {0, 0}; - if (getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur) + if (Q_UNLIKELY(getrlimit(RLIMIT_STACK, &stackLimit) == 0 && stackSize > stackLimit.rlim_cur)) qFatal("Unexpectedly exceeded stack limit"); return stackSize; @@ -250,7 +250,7 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline() unsigned int bufferSize = [arg lengthOfBytesUsingEncoding:cStringEncoding] + 1; argv[i] = reinterpret_cast<char *>(malloc(bufferSize)); - if (![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding]) + if (Q_UNLIKELY(![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding])) qFatal("Could not convert argv[%d] to C string", i); } diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 0e3da8dce8..72c9286f86 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -70,7 +70,7 @@ QIOSIntegration::QIOSIntegration() , m_accessibility(0) , m_debugWindowManagement(false) { - if (![UIApplication sharedApplication]) { + if (Q_UNLIKELY(![UIApplication sharedApplication])) { qFatal("Error: You are creating QApplication before calling UIApplicationMain.\n" \ "If you are writing a native iOS application, and only want to use Qt for\n" \ "parts of the application, a good place to create QApplication is from within\n" \ |