[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:
parent
2de0a18a89
commit
c92d2ea59e
@ -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();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user