QString: scope a loop variable correctly

The variable idx isn't used outside the respective loops, so make it loop-local.

Change-Id: I62807cb244b068ce4df42812a0e4b99a1f488adc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
This commit is contained in:
Marc Mutz 2021-12-16 06:53:33 +01:00
parent 6830bdc140
commit 795e7dd091

View File

@ -10484,10 +10484,9 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
const auto *n = needle + sl_minus_1;
const auto *h = haystack + sl_minus_1;
std::size_t hashNeedle = 0, hashHaystack = 0;
qsizetype idx;
if (cs == Qt::CaseSensitive) {
for (idx = 0; idx < sl; ++idx) {
for (qsizetype idx = 0; idx < sl; ++idx) {
hashNeedle = (hashNeedle << 1) + valueTypeToUtf16(*(n - idx));
hashHaystack = (hashHaystack << 1) + valueTypeToUtf16(*(h - idx));
}
@ -10502,7 +10501,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
REHASH(valueTypeToUtf16(haystack[sl]));
}
} else {
for (idx = 0; idx < sl; ++idx) {
for (qsizetype idx = 0; idx < sl; ++idx) {
hashNeedle = (hashNeedle << 1) + foldCaseHelper(n - idx, needle);
hashHaystack = (hashHaystack << 1) + foldCaseHelper(h - idx, end);
}