summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringview.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-05-05 10:45:19 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-06-11 15:43:00 -0700
commit631901f6d1da84ded3528d26f00ea5fa3bfbf6a2 (patch)
tree118d00d165caf48c0601d9e638e41b1f9b27e96e /src/corelib/text/qstringview.h
parent60f34fc9e368010a5eaae920e5e306e59abf8e73 (diff)
Q{Any,}StringView: remove the GCC-specific compile-time content
Because GCC isn't really working them out at compile time. First, for both lengthHelperPointer(), they don't get called on string literals such as return QStringView(u"Hello"); because the type hasn't decayed to a pointer, but is instead a char16_t[6]. No one writes constexpr auto str = u"Hello"; return QStringView(str); Second, even when you do write that, GCC is emitting the code to search for the null or non-ASCII byte at runtime, instead of pre-calculating it. That's not worth it because the code is not vectorized, even at -O3 and with a long string. Instead, let it get the length at runtime with QtPrivate::qustrlen(), which has vector code. Drive-by fix the QAnyStringView::lengthPointerHelper() to be constexpr, avoiding the same GCC warning that was fixed for QStringView in commit 4fd4082c3ab682f14911e6308ec5ccb400de34f9. Change-Id: Ieab617d69f3b4b54ab30fffd175c505cb66eac02 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r--src/corelib/text/qstringview.h3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h
index 3dc8b5ce0b..24a860c1a6 100644
--- a/src/corelib/text/qstringview.h
+++ b/src/corelib/text/qstringview.h
@@ -108,9 +108,6 @@ private:
#if defined(__cpp_lib_is_constant_evaluated)
if (std::is_constant_evaluated())
return std::char_traits<Char>::length(str);
-#elif defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
- if (__builtin_constant_p(*str))
- return std::char_traits<Char>::length(str);
#endif
return QtPrivate::qustrlen(reinterpret_cast<const char16_t *>(str));
}