diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-10 10:28:50 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-18 21:38:12 -0800 |
commit | 2c2e2a67c3834350c17d7fbb6b26f193eddae426 (patch) | |
tree | 7fc8f33b0c34e31fc7ff73b08925821fdf1d2bbe /src/corelib/text/qstring.cpp | |
parent | ba0864ae52b3f5744cff3ca803b815cd5d1543a0 (diff) |
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 <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
-rw-r--r-- | src/corelib/text/qstring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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<const uchar *>(utf8); auto end1 = reinterpret_cast<const uchar *>(utf8end); |