diff options
author | Daniel Jasper <djasper@google.com> | 2015-11-23 22:28:56 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-11-23 22:28:56 +0000 |
commit | 5a59152fd0e08120876f50f286dbec86f63ec058 (patch) | |
tree | 338d68b8b40ed094fb40777e9569d2e803dfc5f4 /clang-tools-extra/clang-apply-replacements | |
parent | d5d083ccd4bfd242d5c33ad304e4bc027c7c361b (diff) | |
download | bcm5719-llvm-5a59152fd0e08120876f50f286dbec86f63ec058.tar.gz bcm5719-llvm-5a59152fd0e08120876f50f286dbec86f63ec058.zip |
Fix test failure introduced by r253859. I believe that the new behavior
in r253859 makes sense in many cases and thus, I have fixed the
implementation of calculateChangedRanges instead. It had a FIXME anyway
saying that it was unecessarily using shiftedCodePosition which
resulted in O(N^2) runtime.
llvm-svn: 253929
Diffstat (limited to 'clang-tools-extra/clang-apply-replacements')
-rw-r--r-- | clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp index 127e570863b..4603212b825 100644 --- a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp +++ b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp @@ -209,14 +209,11 @@ RangeVector calculateChangedRanges( RangeVector ChangedRanges; // Generate the new ranges from the replacements. - // - // NOTE: This is O(n^2) in the number of replacements. If this starts to - // become a problem inline shiftedCodePosition() here and do shifts in a - // single run through this loop. + int Shift = 0; for (const tooling::Replacement &R : Replaces) { - unsigned Offset = tooling::shiftedCodePosition(Replaces, R.getOffset()); + unsigned Offset = R.getOffset() + Shift; unsigned Length = R.getReplacementText().size(); - + Shift += Length - R.getLength(); ChangedRanges.push_back(tooling::Range(Offset, Length)); } |