From 7f01e20c37aa238cb1e1ebe23ef7b3cdad79e210 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Mar 2025 12:04:39 +0100 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira (cherry picked from commit f8647f8951207b66e3a2d7130fd5f75c3b14b5e6) Reviewed-by: Qt Cherry-pick Bot --- src/network/access/qhttpheaderparser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttpheaderparser.cpp b/src/network/access/qhttpheaderparser.cpp index 744b932c990..8b1dcfb0e68 100644 --- a/src/network/access/qhttpheaderparser.cpp +++ b/src/network/access/qhttpheaderparser.cpp @@ -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); };