aboutsummaryrefslogtreecommitdiff
path: root/lib/Rewrite/HTMLRewrite.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-16 04:11:35 +0000
committerChris Lattner <sabre@nondot.org>2008-04-16 04:11:35 +0000
commit57df3b950061c73d13d3116f747e79d7955a216a (patch)
tree8add0283f5bed9a064c563a09da1052e8e7d8dc9 /lib/Rewrite/HTMLRewrite.cpp
parentb9bc3eca218e2670f05b34c0b3c33a46d710bd88 (diff)
switch AddLineNumber to use a SmallString instead of sstream. This
speeds up -emit-html on ted's testcase by 29% (.138 -> 0.107s) in a release build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49767 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/HTMLRewrite.cpp')
-rw-r--r--lib/Rewrite/HTMLRewrite.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp
index bc7864eebd..fc1627af02 100644
--- a/lib/Rewrite/HTMLRewrite.cpp
+++ b/lib/Rewrite/HTMLRewrite.cpp
@@ -15,6 +15,7 @@
#include "clang/Rewrite/Rewriter.h"
#include "clang/Rewrite/HTMLRewrite.h"
#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/MemoryBuffer.h"
#include <sstream>
@@ -113,17 +114,18 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
static void AddLineNumber(Rewriter& R, unsigned LineNo,
SourceLocation B, SourceLocation E) {
-
- std::ostringstream os;
- os << "<tr><td class=\"num\" id=\"LN" << LineNo << "\">"
- << LineNo << "</td><td class=\"line\">";
-
+ llvm::SmallString<100> Str;
+ Str += "<tr><td class=\"num\" id=\"LN";
+ Str.append_uint(LineNo);
+ Str += "\">";
+ Str.append_uint(LineNo);
+ Str += "</td><td class=\"line\">";
+
if (B == E) { // Handle empty lines.
- os << " </td></tr>";
- R.InsertStrBefore(B, os.str());
- }
- else {
- R.InsertStrBefore(B, os.str());
+ Str += " </td></tr>";
+ R.InsertTextBefore(B, &Str[0], Str.size());
+ } else {
+ R.InsertTextBefore(B, &Str[0], Str.size());
R.InsertCStrBefore(E, "</td></tr>");
}
}