QFontEngine: reduce unnecessary relocations

Instead of static constexpr QL1SV objects (which force the compiler to
allocate storage for them and therefore cause relocations), use mere
automatic constexpr objects (which don't). There never was a need to
make these objects static, as constexpr is enough to force the
compiler to constant-fold them.

Difference:
  qfontengine.cpp.o:
- 0000000000000040 l     O .data.rel.ro.local     0000000000000010 QFontEngine::findGlyph(QLatin1String) const::gid
- 0000000000000000 l     O .data.rel.ro.local     0000000000000010 QFontEngine::findGlyph(QLatin1String) const::uni
  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.

Amends 176816f21324bf736389037c62538a25f2522808.

Pick-to: 6.9
Task-number: QTBUG-100536
Change-Id: I3cdf42c9758ec32654b378a2b27b565a6c92c26b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
This commit is contained in:
Marc Mutz 2025-03-06 12:04:39 +01:00 committed by Volker Hilsheimer
parent 1370ecf293
commit 511ee39570

View File

@ -949,8 +949,8 @@ glyph_t QFontEngine::findGlyph(QLatin1StringView name) const
#endif
if (!result) {
static constexpr auto gid = "gid"_L1;
static constexpr auto uni = "uni"_L1;
constexpr auto gid = "gid"_L1;
constexpr auto uni = "uni"_L1;
if (name.startsWith(gid)) {
bool ok;
result = name.slice(gid.size()).toUInt(&ok);