[clangd][NFC] Use std::string::replace in SourceCode:applyChange.

Just looks nicer and easier to read.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D98274
This commit is contained in:
Nathan James 2021-03-09 21:39:19 +00:00
parent 2de0a18a89
commit c92d2ea59e
No known key found for this signature in database
GPG Key ID: CC007AFCDA90AA5F

View File

@ -1091,15 +1091,8 @@ llvm::Error applyChange(std::string &Contents,
"computed range length ({1}).",
*Change.rangeLength, ComputedRangeLength);
std::string NewContents;
NewContents.reserve(*StartIndex + Change.text.length() +
(Contents.length() - *EndIndex));
Contents.replace(*StartIndex, *EndIndex - *StartIndex, Change.text);
NewContents = Contents.substr(0, *StartIndex);
NewContents += Change.text;
NewContents += Contents.substr(*EndIndex);
std::swap(Contents, NewContents);
return llvm::Error::success();
}