[cfe-commits] r49764 - in /cfe/trunk: Driver/HTMLPrint.cpp include/clang/Rewrite/Rewriter.h

Chris Lattner sabre at nondot.org
Tue Apr 15 20:47:00 PDT 2008


Author: lattner
Date: Tue Apr 15 22:46:57 2008
New Revision: 49764

URL: http://llvm.org/viewvc/llvm-project?rev=49764&view=rev
Log:
speed up -emit-html in a release build by 6.5% by avoiding std::string.

Modified:
    cfe/trunk/Driver/HTMLPrint.cpp
    cfe/trunk/include/clang/Rewrite/Rewriter.h

Modified: cfe/trunk/Driver/HTMLPrint.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLPrint.cpp?rev=49764&r1=49763&r2=49764&view=diff

==============================================================================
--- cfe/trunk/Driver/HTMLPrint.cpp (original)
+++ cfe/trunk/Driver/HTMLPrint.cpp Tue Apr 15 22:46:57 2008
@@ -56,8 +56,10 @@
   // Emit the HTML.
   
   if (const RewriteBuffer *RewriteBuf = R.getRewriteBufferFor(FileID)) {
-    std::string S(RewriteBuf->begin(), RewriteBuf->end());
-    printf("%s\n", S.c_str());
+    char *Buffer = (char*)malloc(RewriteBuf->size());
+    std::copy(RewriteBuf->begin(), RewriteBuf->end(), Buffer);
+    fwrite(Buffer, 1, RewriteBuf->size(), stdout);
+    free(Buffer);
   }
 }
 

Modified: cfe/trunk/include/clang/Rewrite/Rewriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Rewriter.h?rev=49764&r1=49763&r2=49764&view=diff

==============================================================================
--- cfe/trunk/include/clang/Rewrite/Rewriter.h (original)
+++ cfe/trunk/include/clang/Rewrite/Rewriter.h Tue Apr 15 22:46:57 2008
@@ -49,6 +49,7 @@
   typedef BufferTy::const_iterator iterator;
   iterator begin() const { return Buffer.begin(); }
   iterator end() const { return Buffer.end(); }
+  unsigned size() const { return Buffer.size(); }
   
 private:  // Methods only usable by Rewriter.
   





More information about the cfe-commits mailing list