Get rid of StringAppendF().

Change-Id: Iab050177c341ad0642d9af802e86a40736cca2ec
Reviewed-on: https://code-review.googlesource.com/c/re2/+/43072
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/dfa.cc b/re2/dfa.cc
index c740d8a..40880f9 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -509,10 +509,10 @@
   const char* sep = "";
   for (Workq::iterator it = q->begin(); it != q->end(); ++it) {
     if (q->is_mark(*it)) {
-      StringAppendF(&s, "|");
+      s += "|";
       sep = "";
     } else {
-      StringAppendF(&s, "%s%d", sep, *it);
+      s += StringPrintf("%s%d", sep, *it);
       sep = ",";
     }
   }
@@ -529,20 +529,20 @@
     return "*";
   std::string s;
   const char* sep = "";
-  StringAppendF(&s, "(%p)", state);
+  s += StringPrintf("(%p)", state);
   for (int i = 0; i < state->ninst_; i++) {
     if (state->inst_[i] == Mark) {
-      StringAppendF(&s, "|");
+      s += "|";
       sep = "";
     } else if (state->inst_[i] == MatchSep) {
-      StringAppendF(&s, "||");
+      s += "||";
       sep = "";
     } else {
-      StringAppendF(&s, "%s%d", sep, state->inst_[i]);
+      s += StringPrintf("%s%d", sep, state->inst_[i]);
       sep = ",";
     }
   }
-  StringAppendF(&s, " flag=%#x", state->flag_);
+  s += StringPrintf(" flag=%#x", state->flag_);
   return s;
 }
 
diff --git a/re2/nfa.cc b/re2/nfa.cc
index e459b6f..7bb4faf 100644
--- a/re2/nfa.cc
+++ b/re2/nfa.cc
@@ -429,13 +429,14 @@
   std::string s;
   for (int i = 0; i < ncapture_; i+=2) {
     if (capture[i] == NULL)
-      StringAppendF(&s, "(?,?)");
+      s += "(?,?)";
     else if (capture[i+1] == NULL)
-      StringAppendF(&s, "(%d,?)", (int)(capture[i] - btext_));
+      s += StringPrintf("(%d,?)",
+                        (int)(capture[i] - btext_));
     else
-      StringAppendF(&s, "(%d,%d)",
-                    (int)(capture[i] - btext_),
-                    (int)(capture[i+1] - btext_));
+      s += StringPrintf("(%d,%d)",
+                        (int)(capture[i] - btext_),
+                        (int)(capture[i+1] - btext_));
   }
   return s;
 }
diff --git a/re2/onepass.cc b/re2/onepass.cc
index e04c56d..d615893 100644
--- a/re2/onepass.cc
+++ b/re2/onepass.cc
@@ -597,15 +597,15 @@
       if (nodeindex == -1)
         continue;
       OneState* node = IndexToNode(nodes.data(), statesize, nodeindex);
-      StringAppendF(&dump, "node %d id=%d: matchcond=%#x\n",
-                    nodeindex, id, node->matchcond);
+      dump += StringPrintf("node %d id=%d: matchcond=%#x\n",
+                           nodeindex, id, node->matchcond);
       for (int i = 0; i < bytemap_range_; i++) {
         if ((node->action[i] & kImpossible) == kImpossible)
           continue;
-        StringAppendF(&dump, "  %d cond %#x -> %d id=%d\n",
-                      i, node->action[i] & 0xFFFF,
-                      node->action[i] >> kIndexShift,
-                      idmap[node->action[i] >> kIndexShift]);
+        dump += StringPrintf("  %d cond %#x -> %d id=%d\n",
+                             i, node->action[i] & 0xFFFF,
+                             node->action[i] >> kIndexShift,
+                             idmap[node->action[i] >> kIndexShift]);
       }
     }
     LOG(ERROR) << "nodes:\n" << dump;
diff --git a/re2/prog.cc b/re2/prog.cc
index 9853d6d..5155943 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -134,7 +134,7 @@
   for (Workq::iterator i = q->begin(); i != q->end(); ++i) {
     int id = *i;
     Prog::Inst* ip = prog->inst(id);
-    StringAppendF(&s, "%d. %s\n", id, ip->Dump().c_str());
+    s += StringPrintf("%d. %s\n", id, ip->Dump().c_str());
     AddToQueue(q, ip->out());
     if (ip->opcode() == kInstAlt || ip->opcode() == kInstAltMatch)
       AddToQueue(q, ip->out1());
@@ -147,9 +147,9 @@
   for (int id = start; id < prog->size(); id++) {
     Prog::Inst* ip = prog->inst(id);
     if (ip->last())
-      StringAppendF(&s, "%d. %s\n", id, ip->Dump().c_str());
+      s += StringPrintf("%d. %s\n", id, ip->Dump().c_str());
     else
-      StringAppendF(&s, "%d+ %s\n", id, ip->Dump().c_str());
+      s += StringPrintf("%d+ %s\n", id, ip->Dump().c_str());
   }
   return s;
 }
@@ -180,7 +180,7 @@
     while (c < 256-1 && bytemap_[c+1] == b)
       c++;
     int hi = c;
-    StringAppendF(&map, "[%02x-%02x] -> %d\n", lo, hi, b);
+    map += StringPrintf("[%02x-%02x] -> %d\n", lo, hi, b);
   }
   return map;
 }
diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc
index 9430bbc..fb3cc14 100644
--- a/re2/testing/dfa_test.cc
+++ b/re2/testing/dfa_test.cc
@@ -360,12 +360,12 @@
     prog->BuildEntireDFA(Prog::kLongestMatch, [&](const int* next, bool match) {
       ASSERT_TRUE(next != NULL);
       if (!dump.empty())
-        StringAppendF(&dump, " ");
-      StringAppendF(&dump, match ? "[[" : "[");
+        dump += " ";
+      dump += match ? "[[" : "[";
       for (int b = 0; b < prog->bytemap_range() + 1; b++)
-        StringAppendF(&dump, "%d,", next[b]);
+        dump += StringPrintf("%d,", next[b]);
       dump.pop_back();
-      StringAppendF(&dump, match ? "]]" : "]");
+      dump += match ? "]]" : "]";
     });
     if (dump != t.dump) {
       LOG(ERROR) << t.regexp << " bytemap:\n" << prog->DumpByteMap();
diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc
index 743f7b5..1df8ddd 100644
--- a/re2/testing/dump.cc
+++ b/re2/testing/dump.cc
@@ -59,7 +59,7 @@
 // Nothing pretty, just for testing.
 static void DumpRegexpAppending(Regexp* re, std::string* s) {
   if (re->op() < 0 || re->op() >= arraysize(kOpcodeNames)) {
-    StringAppendF(s, "op%d", re->op());
+    *s += StringPrintf("op%d", re->op());
   } else {
     switch (re->op()) {
       default:
diff --git a/re2/tostring.cc b/re2/tostring.cc
index a608c87..4545a92 100644
--- a/re2/tostring.cc
+++ b/re2/tostring.cc
@@ -332,10 +332,10 @@
   }
 
   if (r < 0x100) {
-    StringAppendF(t, "\\x%02x", static_cast<int>(r));
+    *t += StringPrintf("\\x%02x", static_cast<int>(r));
     return;
   }
-  StringAppendF(t, "\\x{%x}", static_cast<int>(r));
+  *t += StringPrintf("\\x{%x}", static_cast<int>(r));
 }
 
 static void AppendCCRange(std::string* t, Rune lo, Rune hi) {
diff --git a/util/strutil.cc b/util/strutil.cc
index d37aa0c..fb7e6b1 100644
--- a/util/strutil.cc
+++ b/util/strutil.cc
@@ -146,11 +146,4 @@
   return result;
 }
 
-void StringAppendF(std::string* dst, const char* format, ...) {
-  va_list ap;
-  va_start(ap, format);
-  StringAppendV(dst, format, ap);
-  va_end(ap);
-}
-
 }  // namespace re2
diff --git a/util/strutil.h b/util/strutil.h
index 37fb359..a69908a 100644
--- a/util/strutil.h
+++ b/util/strutil.h
@@ -15,7 +15,6 @@
 std::string CEscape(const StringPiece& src);
 void PrefixSuccessor(std::string* prefix);
 std::string StringPrintf(const char* format, ...);
-void StringAppendF(std::string* dst, const char* format, ...);
 
 }  // namespace re2