QHttpHeaderParser: remove unneeded relocations

Instead of a static constexpr QL1SV object (which force the compiler
to allocate storage and therefore causes relocations), use a mere
automatic constexpr object (which doesn't). There never was a need to
make this object static, as constexpr is enough to force the compiler
to constant-fold them. The lambda doesn't have access without a
capture, of course, but that is easily solved my moving the object
definition into the lambda itself.

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to detect these issues.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

Amends 18aff2b424577b4560b32698038e9bcf68a54b88.

While at it, remove the static from the lambda, too. While it doesn't
cause relocations, it might, on weaker compilers, cause a thread-safe
static prologue to be emitted, and it's not needed, either.

Pick-to: 6.8 6.5
Task-number: QTBUG-100536
Change-Id: Iaede4d02a84ea2e49b42f3da93a77cb8391df5bb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f8647f8951207b66e3a2d7130fd5f75c3b14b5e6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-03-06 12:04:39 +01:00 committed by Qt Cherry-pick Bot
parent a872a3a73c
commit 7f01e20c37

View File

@ -26,8 +26,8 @@ void QHttpHeaderParser::clear()
static bool fieldNameCheck(QByteArrayView name)
{
static constexpr QByteArrayView otherCharacters("!#$%&'*+-.^_`|~");
static const auto fieldNameChar = [](char c) {
const auto fieldNameChar = [](char c) {
constexpr QByteArrayView otherCharacters("!#$%&'*+-.^_`|~");
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9')
|| otherCharacters.contains(c);
};