From a069569ea2026ee4c2b4fda63d321eb0e104527b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 6 Mar 2025 12:04:39 +0100 Subject: [PATCH] QTextMarkdownWriter: reduce unnecessary 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. Difference: qtextmarkdownwriter.cpp.o: - 0000000000000000 l O .data.rel.ro.local 0000000000000010 maybeEscapeFirstChar(QString&)::specialFirstCharacters 0000000000000000 l d .data.rel.ro.local 0000000000000000 .data.rel.ro.local See https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343 for the script to generate this output. See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why we care. As a drive-by, port from QL1SV to _L1 UDL. Amends ca4774131b9b8ee40b4d7f5c1ba296af4700207f. Pick-to: 6.8 Task-number: QTBUG-100536 Change-Id: I31e124962e03b8b40df9153b09f627e8e22a8119 Reviewed-by: Matthias Rauter (cherry picked from commit db6f8821fcf0028f83b4c27c8de2399c99577272) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/qtextmarkdownwriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 2e23dfcd944..7a6a43d2057 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -298,7 +298,7 @@ static int adjacentBackticksCount(const QString &s) static void maybeEscapeFirstChar(QString &s) { static const QRegularExpression numericListRe(uR"(\d+([\.)])\s)"_s); - static const QLatin1StringView specialFirstCharacters("#*+-"); + constexpr auto specialFirstCharacters = "#*+-"_L1; QString sTrimmed = s.trimmed(); if (sTrimmed.isEmpty())