[PATCH] D98274: [clangd][NFC] Use std::string::replace in SourceCode:applyChange.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 9 13:39:37 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc92d2ea59e79: [clangd][NFC] Use std::string::replace in SourceCode:applyChange. (authored by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98274/new/
https://reviews.llvm.org/D98274
Files:
clang-tools-extra/clangd/SourceCode.cpp
Index: clang-tools-extra/clangd/SourceCode.cpp
===================================================================
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -1091,15 +1091,8 @@
"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();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98274.329458.patch
Type: text/x-patch
Size: 763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210309/16c0bf47/attachment.bin>
More information about the cfe-commits
mailing list