From 2c2e2a67c3834350c17d7fbb6b26f193eddae426 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Jan 2022 10:28:50 -0800 Subject: QString: add Q_NEVER_INLINE for ucstricmp() Case-insensitive comparisons are not common, but both GCC and Clang inlined the ucstricmp() functions into QtPrivate::compareStrings(), with the side-effect that a lot of unnecessary setup code saving CPU registers was executed in the prologue of those functions. After this, Clang 13 emits both compareString() functions without any push/pop to save registers on x86-64; GCC 11 still emits a few, but fewer than before (it's emitting some unnecessary overhead for the loops). Change-Id: I0e5f6bec596a4a78bd3bfffd16c8fc2c0be9165f Reviewed-by: Marc Mutz --- src/corelib/text/qstring.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/text/qstring.cpp') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 0b5aa5a885..b5f884f2ad 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1006,7 +1006,7 @@ void qt_to_latin1_unchecked(uchar *dst, const char16_t *src, qsizetype length) } // Unicode case-insensitive comparison -static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QChar *be) +Q_NEVER_INLINE static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QChar *be) { if (a == b) return (ae - be); @@ -1036,7 +1036,7 @@ static int ucstricmp(const QChar *a, const QChar *ae, const QChar *b, const QCha } // Case-insensitive comparison between a Unicode string and a QLatin1String -static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char *be) +Q_NEVER_INLINE static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char *be) { auto e = ae; if (be - b < ae - a) @@ -1058,7 +1058,7 @@ static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char } // Case-insensitive comparison between a Unicode string and a UTF-8 string -static int ucstricmp8(const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end) +Q_NEVER_INLINE static int ucstricmp8(const char *utf8, const char *utf8end, const QChar *utf16, const QChar *utf16end) { auto src1 = reinterpret_cast(utf8); auto end1 = reinterpret_cast(utf8end); -- cgit v1.2.3