summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-08-02 18:41:30 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-08-22 02:32:57 +0200
commitb61fb33be831eaa23ccc2d0876f8bc4a762318e9 (patch)
treed9e4c84298a54838e9ad4ae5fbebb148cc73ae5b /src/corelib/kernel/qobject.cpp
parentdb05d302150b28a1bc4362eecd197a57d98bfe65 (diff)
QLocale: fix Coverity complaint about a missing std::move()
Coverity complains that we should have moved 'entry' into 'prefix'. Since there are another 60-70 LOC following in that scope, it would harm readabilty if we simply did that. We'd also need to make 'entry' non-const, futher complicating the function by turning a constant into yet another variable. Instead, move the definition of 'prefix' into the loop body as a local variable (capturing the result of QString::first(), saving a move-assignment as a drive-by). Since 'prefix' is now a loop-iteration-local variable, we can, at the end of the loop, move it into uiLanguages. _That_ move is ok, readability-wise, because it happens at the end of the scope. We can't keep iterating over prefix.lastIndexOf(), of course, so iterate over 'entry' instead. That means we need to remember the last separator's position, which isn't a problem, since there's already a variable for it. We just need to adjust its initial value and pass it as 'from' to lastIndexOf(). Note that this is safe even if entry.isEmpty() (which shouldn't happen, since empty string shouldn't be in uiLanguages). Amends 2c39365aad957aea7ca9c9c861665391edf7ef23. Coverity-Id: 474044 Pick-to: 6.10 6.9 Change-Id: I2d809dc5e4d5c014141805db31ea7f8f1dfa5010 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
0 files changed, 0 insertions, 0 deletions