Utils: Cleanup SmallString::replace

Improve the naming of the variables.

Change-Id: I125f3451e0e6a7437909067e9bff06cbeac111a0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-08-03 15:17:35 +02:00
committed by Tim Jenssen
parent 0e3dc045a1
commit 18453deafb

View File

@@ -866,32 +866,30 @@ private:
auto foundIndex = found - begin(); auto foundIndex = found - begin();
if (found != end()) { if (found != end()) {
startIndex = foundIndex + fromText.size(); size_type startNextSearchIndex = foundIndex + fromText.size();
size_type newSizeDifference = sizeDifference + (toText.size() - fromText.size());
size_type newSizeDifference = sizeDifference + toText.size() - fromText.size(); auto nextFound = replaceLargerSizedRecursive(startNextSearchIndex,
auto nextFound = replaceLargerSizedRecursive(startIndex,
fromText, fromText,
toText, toText,
newSizeDifference); newSizeDifference);
found = begin() + foundIndex; auto startFound = begin() + foundIndex;
auto start = begin() + startIndex; auto endOfFound = begin() + startNextSearchIndex;
auto replacedTextEndPosition = found + fromText.size();
auto replacementTextEndPosition = found + fromText.size() + newSizeDifference;
auto replacementTextStartPosition = found + sizeDifference;
auto replacedTextEndPosition = endOfFound;
auto replacementTextEndPosition = endOfFound + newSizeDifference;
auto replacementTextStartPosition = startFound + sizeDifference;
std::memmove(replacementTextEndPosition.data(), std::memmove(replacementTextEndPosition.data(),
replacedTextEndPosition.data(), replacedTextEndPosition.data(),
nextFound - start); std::distance(endOfFound, nextFound));
std::memcpy(replacementTextStartPosition.data(), toText.data(), toText.size()); std::memcpy(replacementTextStartPosition.data(), toText.data(), toText.size());
} else { } else {
size_type newSize = size() + sizeDifference; size_type newSize = size() + sizeDifference;
reserve(optimalCapacity(newSize)); reserve(optimalCapacity(newSize));
setSize(newSize); setSize(newSize);
*end() = 0; at(newSize) = 0;
} }
return begin() + foundIndex; return begin() + foundIndex;