QIODevice: mark checkWarnMessage() as Q_DECL_COLD_FUNCTION

It's only called in exceptional circumstances, so the compiler should
optimize it for size, not speed, and paths leading up to calls to this
functions should be automatically marked as [[unlikely]].

Marking the function as cold accomplishes both.

GCC 11 seems to have had this figured out by itself, possibly
backtracking from the unconditional qWarning() in the first line of
the function, but it did have a (very small) effect on Clang 15, so
leave it in, if only as documentation.

Pick-to: 6.5 6.2
Change-Id: Ie8e9049300825a3aae2f9678a2907ceea0b21d1c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 546208f0ff23819d216cbb5bf0b5daded79b454e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-10-18 10:43:22 +02:00 committed by Qt Cherry-pick Bot
parent bd242a7d2d
commit e789ea584f

View File

@ -45,6 +45,7 @@ static void debugBinaryString(const char *input, qint64 maxlen)
#define Q_VOID
Q_DECL_COLD_FUNCTION
static void checkWarnMessage(const QIODevice *device, const char *function, const char *what)
{
#ifndef QT_NO_WARNING_OUTPUT