]> granicus.if.org Git - clang/commitdiff
Use raw_svector_ostream for string concatenation.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 19 Aug 2009 18:30:37 +0000 (18:30 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 19 Aug 2009 18:30:37 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79444 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/HTMLRewrite.cpp

index bc29431dc3b1e712a55d1c1209587e75074941d0..68edda222b28e55d35a9c6e9e73963ae8b98e1ac 100644 (file)
@@ -202,17 +202,19 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
 
 static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo,
                           unsigned B, unsigned E) {
-  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\">";
+  llvm::SmallString<256> Str;
+  llvm::raw_svector_ostream OS(Str);
+
+  OS << "<tr><td class=\"num\" id=\"LN"
+     << LineNo << "\">"
+     << LineNo << "</td><td class=\"line\">";
   
   if (B == E) { // Handle empty lines.
-    Str += " </td></tr>";
+    OS << " </td></tr>";
+    OS.flush();
     RB.InsertTextBefore(B, &Str[0], Str.size());
   } else {
+    OS.flush();
     RB.InsertTextBefore(B, &Str[0], Str.size());
     RB.InsertTextBefore(E, "</td></tr>", strlen("</td></tr>"));
   }