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
This commit is contained in:
parent
d5d083ccd4
commit
5a59152fd0
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue