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();
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(startIndex,
auto nextFound = replaceLargerSizedRecursive(startNextSearchIndex,
fromText,
toText,
newSizeDifference);
found = begin() + foundIndex;
auto start = begin() + startIndex;
auto replacedTextEndPosition = found + fromText.size();
auto replacementTextEndPosition = found + fromText.size() + newSizeDifference;
auto replacementTextStartPosition = found + sizeDifference;
auto startFound = begin() + foundIndex;
auto endOfFound = begin() + startNextSearchIndex;
auto replacedTextEndPosition = endOfFound;
auto replacementTextEndPosition = endOfFound + newSizeDifference;
auto replacementTextStartPosition = startFound + sizeDifference;
std::memmove(replacementTextEndPosition.data(),
replacedTextEndPosition.data(),
nextFound - start);
std::distance(endOfFound, nextFound));
std::memcpy(replacementTextStartPosition.data(), toText.data(), toText.size());
} else {
size_type newSize = size() + sizeDifference;
reserve(optimalCapacity(newSize));
setSize(newSize);
*end() = 0;
at(newSize) = 0;
}
return begin() + foundIndex;