summaryrefslogtreecommitdiffstats
path: root/clang/lib/Rewrite/Core
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-02 17:02:49 +0000
committerAlp Toker <alp@nuanti.com>2013-12-02 17:02:49 +0000
commitd505d403604a5a253f4dc3adcf1c0fcb343aa62c (patch)
treeb1685f9d2c5484f62f708d5e45122d89e4d691c9 /clang/lib/Rewrite/Core
parenta26fcc7989405df40ba181bd13678cab6f651723 (diff)
downloadbcm5719-llvm-d505d403604a5a253f4dc3adcf1c0fcb343aa62c.tar.gz
bcm5719-llvm-d505d403604a5a253f4dc3adcf1c0fcb343aa62c.zip
Rewriter: Output RewriteRope contents efficiently
This avoids allocation of temporary std::strings for file contents, instead writing chunks directly to the output stream. The old character-based B-tree iterator remains intact for the time being. llvm-svn: 196119
Diffstat (limited to 'clang/lib/Rewrite/Core')
-rw-r--r--clang/lib/Rewrite/Core/Rewriter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Rewrite/Core/Rewriter.cpp b/clang/lib/Rewrite/Core/Rewriter.cpp
index afb1080c66a..51af83954c5 100644
--- a/clang/lib/Rewrite/Core/Rewriter.cpp
+++ b/clang/lib/Rewrite/Core/Rewriter.cpp
@@ -26,8 +26,11 @@
using namespace clang;
raw_ostream &RewriteBuffer::write(raw_ostream &os) const {
- // FIXME: eliminate the copy by writing out each chunk at a time
- os << std::string(begin(), end());
+ // Walk RewriteRope chunks efficiently using MoveToNextPiece() instead of the
+ // character iterator.
+ for (RopePieceBTreeIterator I = begin(), E = end(); I != E;
+ I.MoveToNextPiece())
+ os << I.piece();
return os;
}
OpenPOWER on IntegriCloud