[cfe-commits] r43348 - /cfe/trunk/Rewrite/Rewriter.cpp
Chris Lattner
sabre at nondot.org
Thu Oct 25 10:18:59 PDT 2007
Author: lattner
Date: Thu Oct 25 12:18:59 2007
New Revision: 43348
URL: http://llvm.org/viewvc/llvm-project?rev=43348&view=rev
Log:
simplify change.
Modified:
cfe/trunk/Rewrite/Rewriter.cpp
Modified: cfe/trunk/Rewrite/Rewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Rewrite/Rewriter.cpp?rev=43348&r1=43347&r2=43348&view=diff
==============================================================================
--- cfe/trunk/Rewrite/Rewriter.cpp (original)
+++ cfe/trunk/Rewrite/Rewriter.cpp Thu Oct 25 12:18:59 2007
@@ -159,27 +159,22 @@
if (StartFileID != EndFileID)
return -1;
- unsigned Delta;
-
- // If no edits have been made to this buffer, the delta between the range
- // Is just the difference in offsets.
+ // If edits have been made to this buffer, the delta between the range may
+ // have changed.
std::map<unsigned, RewriteBuffer>::const_iterator I =
RewriteBuffers.find(StartFileID);
- if (I == RewriteBuffers.end()) {
- Delta = EndOff-StartOff;
- } else {
- // Otherwise, subtracted the mapped offsets instead.
+ if (I != RewriteBuffers.end()) {
const RewriteBuffer &RB = I->second;
- Delta = RB.getMappedOffset(EndOff, true);
- Delta -= RB.getMappedOffset(StartOff);
+ EndOff = RB.getMappedOffset(EndOff, true);
+ StartOff = RB.getMappedOffset(StartOff);
}
// Adjust the end offset to the end of the last token, instead of being the
// start of the last token.
- Delta += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr);
+ EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr);
- return Delta;
+ return EndOff-StartOff;
}
More information about the cfe-commits
mailing list