summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/cmake-macros/examples.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-07-31 20:48:42 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-08-01 18:47:43 +0000
commite5c207f96261fc218819e70fb47c1f2cafacfc67 (patch)
treeabe9aa1a8f895964f571d1eb34fd9b16f78eb31c /src/widgets/doc/snippets/cmake-macros/examples.cpp
parent7530a86df81b60621eb0813fba684d618060f1ad (diff)
QLocale/Unix: remove "interesting" use of QStringTokenizer
The old code used QStringTokenizer to tokenize a string in a loop, but unconditionally exited the loop after the first iteration. There's a comment saying we're only interested in the first element, but I remember raising my eyebrows when I saw this code for the first time. Now I found that Coverity agrees and flags this as "structurally dead code". Fix by using indexOf() + truncate() on the string instead of tokenize() or (before 0108275b0c6a38ac73014c8e135b9be9fe75c8b2) split(). Since qEnvironmentVariable() returns an unshared QString, this is a cheap operation even on an owning container, so we don't need to use views. Amends 0108275b0c6a38ac73014c8e135b9be9fe75c8b2 for the Coverity warning, but the code before that was even worse: split().first(), so I'm going with amends 897e19f95ee91ec21bb9dd9f3157ee7333c9018f here. Coverity-Id: 444295 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I162bb58003eb18fa533199a6941455294f9d3b07 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/widgets/doc/snippets/cmake-macros/examples.cpp')
0 files changed, 0 insertions, 0 deletions