Skip to content

Commit c92d2ea

Browse files
committed
[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
1 parent 2de0a18 commit c92d2ea

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

clang-tools-extra/clangd/SourceCode.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,15 +1091,8 @@ llvm::Error applyChange(std::string &Contents,
10911091
"computed range length ({1}).",
10921092
*Change.rangeLength, ComputedRangeLength);
10931093

1094-
std::string NewContents;
1095-
NewContents.reserve(*StartIndex + Change.text.length() +
1096-
(Contents.length() - *EndIndex));
1094+
Contents.replace(*StartIndex, *EndIndex - *StartIndex, Change.text);
10971095

1098-
NewContents = Contents.substr(0, *StartIndex);
1099-
NewContents += Change.text;
1100-
NewContents += Contents.substr(*EndIndex);
1101-
1102-
std::swap(Contents, NewContents);
11031096
return llvm::Error::success();
11041097
}
11051098

0 commit comments

Comments
 (0)