Get rid of `using std::string;`. (part 4 of N)

Change-Id: I085c6d217b615ae5284e11743b3aed42b55142fc
Reviewed-on: https://code-review.googlesource.com/c/re2/+/39130
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/parse.cc b/re2/parse.cc
index c8dea7e..f0a1387 100644
--- a/re2/parse.cc
+++ b/re2/parse.cc
@@ -610,7 +610,7 @@
   Regexp* re = new Regexp(kLeftParen, flags_);
   re->cap_ = ++ncap_;
   if (name.data() != NULL)
-    re->name_ = new string(name);
+    re->name_ = new std::string(name);
   return PushRegexp(re);
 }
 
@@ -1790,7 +1790,7 @@
   // Look up the group in the ICU Unicode data. Because ICU provides full
   // Unicode properties support, this could be more than a lookup by name.
   ::icu::UnicodeString ustr = ::icu::UnicodeString::fromUTF8(
-      string("\\p{") + string(name) + string("}"));
+      std::string("\\p{") + std::string(name) + std::string("}"));
   UErrorCode uerr = U_ZERO_ERROR;
   ::icu::UnicodeSet uset(ustr, uerr);
   if (U_FAILURE(uerr)) {
@@ -2181,7 +2181,7 @@
 // into UTF8 encoding in string.
 // Can't use EncodingUtils::EncodeLatin1AsUTF8 because it is
 // deprecated and because it rejects code points 0x80-0x9F.
-void ConvertLatin1ToUTF8(const StringPiece& latin1, string* utf) {
+void ConvertLatin1ToUTF8(const StringPiece& latin1, std::string* utf) {
   char buf[UTFmax];
 
   utf->clear();
@@ -2208,7 +2208,7 @@
 
   // Convert regexp to UTF-8 (easier on the rest of the parser).
   if (global_flags & Latin1) {
-    string* tmp = new string;
+    std::string* tmp = new std::string;
     ConvertLatin1ToUTF8(t, tmp);
     status->set_tmp(tmp);
     t = *tmp;
diff --git a/re2/prefilter.cc b/re2/prefilter.cc
index b657357..4d6df8d 100644
--- a/re2/prefilter.cc
+++ b/re2/prefilter.cc
@@ -21,8 +21,8 @@
 
 static const bool ExtraDebug = false;
 
-typedef std::set<string>::iterator SSIter;
-typedef std::set<string>::const_iterator ConstSSIter;
+typedef std::set<std::string>::iterator SSIter;
+typedef std::set<std::string>::const_iterator ConstSSIter;
 
 // Initializes a Prefilter, allocating subs_ as necessary.
 Prefilter::Prefilter(Op op) {
@@ -140,7 +140,7 @@
   return AndOr(OR, a, b);
 }
 
-static void SimplifyStringSet(std::set<string> *ss) {
+static void SimplifyStringSet(std::set<std::string> *ss) {
   // Now make sure that the strings aren't redundant.  For example, if
   // we know "ab" is a required string, then it doesn't help at all to
   // know that "abc" is also a required string, so delete "abc". This
@@ -155,13 +155,13 @@
       // Increment j early so that we can erase the element it points to.
       SSIter old_j = j;
       ++j;
-      if (old_j->find(*i) != string::npos)
+      if (old_j->find(*i) != std::string::npos)
         ss->erase(old_j);
     }
   }
 }
 
-Prefilter* Prefilter::OrStrings(std::set<string>* ss) {
+Prefilter* Prefilter::OrStrings(std::set<std::string>* ss) {
   SimplifyStringSet(ss);
   Prefilter* or_prefilter = NULL;
   if (!ss->empty()) {
@@ -191,7 +191,7 @@
   return r;
 }
 
-Prefilter* Prefilter::FromString(const string& str) {
+Prefilter* Prefilter::FromString(const std::string& str) {
   Prefilter* m = new Prefilter(Prefilter::ATOM);
   m->atom_ = str;
   return m;
@@ -221,19 +221,19 @@
   static Info* AnyMatch();
 
   // Format Info as a string.
-  string ToString();
+  std::string ToString();
 
   // Caller takes ownership of the Prefilter.
   Prefilter* TakeMatch();
 
-  std::set<string>& exact() { return exact_; }
+  std::set<std::string>& exact() { return exact_; }
 
   bool is_exact() const { return is_exact_; }
 
   class Walker;
 
  private:
-  std::set<string> exact_;
+  std::set<std::string> exact_;
 
   // When is_exact_ is true, the strings that match
   // are placed in exact_. When it is no longer an exact
@@ -268,13 +268,11 @@
 }
 
 // Format a Info in string form.
-string Prefilter::Info::ToString() {
+std::string Prefilter::Info::ToString() {
   if (is_exact_) {
     int n = 0;
-    string s;
-    for (std::set<string>::iterator i = exact_.begin();
-         i != exact_.end();
-         ++i) {
+    std::string s;
+    for (SSIter i = exact_.begin(); i != exact_.end(); ++i) {
       if (n++ > 0)
         s += ",";
       s += *i;
@@ -289,17 +287,17 @@
 }
 
 // Add the strings from src to dst.
-static void CopyIn(const std::set<string>& src,
-                   std::set<string>* dst) {
+static void CopyIn(const std::set<std::string>& src,
+                   std::set<std::string>* dst) {
   for (ConstSSIter i = src.begin(); i != src.end(); ++i)
     dst->insert(*i);
 }
 
 // Add the cross-product of a and b to dst.
 // (For each string i in a and j in b, add i+j.)
-static void CrossProduct(const std::set<string>& a,
-                         const std::set<string>& b,
-                         std::set<string>* dst) {
+static void CrossProduct(const std::set<std::string>& a,
+                         const std::set<std::string>& b,
+                         std::set<std::string>* dst) {
   for (ConstSSIter i = a.begin(); i != a.end(); ++i)
     for (ConstSSIter j = b.begin(); j != b.end(); ++j)
       dst->insert(*i + *j);
@@ -390,15 +388,15 @@
   return ab;
 }
 
-static string RuneToString(Rune r) {
+static std::string RuneToString(Rune r) {
   char buf[UTFmax];
   int n = runetochar(buf, &r);
-  return string(buf, n);
+  return std::string(buf, n);
 }
 
-static string RuneToStringLatin1(Rune r) {
+static std::string RuneToStringLatin1(Rune r) {
   char c = r & 0xff;
-  return string(&c, 1);
+  return std::string(&c, 1);
 }
 
 // Constructs Info for literal rune.
@@ -662,7 +660,7 @@
   return m;
 }
 
-string Prefilter::DebugString() const {
+std::string Prefilter::DebugString() const {
   switch (op_) {
     default:
       LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_;
@@ -674,7 +672,7 @@
     case ALL:
       return "";
     case AND: {
-      string s = "";
+      std::string s = "";
       for (size_t i = 0; i < subs_->size(); i++) {
         if (i > 0)
           s += " ";
@@ -684,7 +682,7 @@
       return s;
     }
     case OR: {
-      string s = "(";
+      std::string s = "(";
       for (size_t i = 0; i < subs_->size(); i++) {
         if (i > 0)
           s += "|";
diff --git a/re2/prefilter.h b/re2/prefilter.h
index ead09e1..4fedeb4 100644
--- a/re2/prefilter.h
+++ b/re2/prefilter.h
@@ -37,7 +37,7 @@
   ~Prefilter();
 
   Op op() { return op_; }
-  const string& atom() const { return atom_; }
+  const std::string& atom() const { return atom_; }
   void set_unique_id(int id) { unique_id_ = id; }
   int unique_id() const { return unique_id_; }
 
@@ -57,7 +57,7 @@
   static Prefilter* FromRE2(const RE2* re2);
 
   // Returns a readable debug string of the prefilter.
-  string DebugString() const;
+  std::string DebugString() const;
 
  private:
   class Info;
@@ -75,9 +75,9 @@
 
   static Prefilter* FromRegexp(Regexp* a);
 
-  static Prefilter* FromString(const string& str);
+  static Prefilter* FromString(const std::string& str);
 
-  static Prefilter* OrStrings(std::set<string>* ss);
+  static Prefilter* OrStrings(std::set<std::string>* ss);
 
   static Info* BuildInfo(Regexp* re);
 
@@ -90,7 +90,7 @@
   std::vector<Prefilter*>* subs_;
 
   // Actual string to match in leaf node.
-  string atom_;
+  std::string atom_;
 
   // If different prefilters have the same string atom, or if they are
   // structurally the same (e.g., OR of same atom strings) they are
diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc
index a07de40..187e2ec 100644
--- a/re2/prefilter_tree.cc
+++ b/re2/prefilter_tree.cc
@@ -54,7 +54,7 @@
   prefilter_vec_.push_back(prefilter);
 }
 
-void PrefilterTree::Compile(std::vector<string>* atom_vec) {
+void PrefilterTree::Compile(std::vector<std::string>* atom_vec) {
   if (compiled_) {
     LOG(DFATAL) << "Compile called already.";
     return;
@@ -106,16 +106,16 @@
 }
 
 Prefilter* PrefilterTree::CanonicalNode(NodeMap* nodes, Prefilter* node) {
-  string node_string = NodeString(node);
-  std::map<string, Prefilter*>::iterator iter = nodes->find(node_string);
+  std::string node_string = NodeString(node);
+  std::map<std::string, Prefilter*>::iterator iter = nodes->find(node_string);
   if (iter == nodes->end())
     return NULL;
   return (*iter).second;
 }
 
-string PrefilterTree::NodeString(Prefilter* node) const {
+std::string PrefilterTree::NodeString(Prefilter* node) const {
   // Adding the operation disambiguates AND/OR/atom nodes.
-  string s = StringPrintf("%d", node->op()) + ":";
+  std::string s = StringPrintf("%d", node->op()) + ":";
   if (node->op() == Prefilter::ATOM) {
     s += node->atom();
   } else {
@@ -166,7 +166,7 @@
 }
 
 void PrefilterTree::AssignUniqueIds(NodeMap* nodes,
-                                    std::vector<string>* atom_vec) {
+                                    std::vector<std::string>* atom_vec) {
   atom_vec->clear();
 
   // Build vector of all filter nodes, sorted topologically
@@ -377,15 +377,14 @@
       LOG(ERROR) << it->first;
   }
   LOG(ERROR) << "Map:";
-  for (std::map<string, Prefilter*>::const_iterator iter = nodes->begin();
+  for (std::map<std::string, Prefilter*>::const_iterator iter = nodes->begin();
        iter != nodes->end(); ++iter)
     LOG(ERROR) << "NodeId: " << (*iter).second->unique_id()
                << " Str: " << (*iter).first;
 }
 
-string PrefilterTree::DebugNodeString(Prefilter* node) const {
-  string node_string = "";
-
+std::string PrefilterTree::DebugNodeString(Prefilter* node) const {
+  std::string node_string = "";
   if (node->op() == Prefilter::ATOM) {
     DCHECK(!node->atom().empty());
     node_string += node->atom();
diff --git a/re2/prefilter_tree.h b/re2/prefilter_tree.h
index f81e134..10d6f7c 100644
--- a/re2/prefilter_tree.h
+++ b/re2/prefilter_tree.h
@@ -43,7 +43,7 @@
   // The caller should use the returned set of strings to do string matching.
   // Each time a string matches, the corresponding index then has to be
   // and passed to RegexpsGivenStrings below.
-  void Compile(std::vector<string>* atom_vec);
+  void Compile(std::vector<std::string>* atom_vec);
 
   // Given the indices of the atoms that matched, returns the indexes
   // of regexps that should be searched.  The matched_atoms should
@@ -60,7 +60,7 @@
  private:
   typedef SparseArray<int> IntMap;
   typedef std::map<int, int> StdIntMap;
-  typedef std::map<string, Prefilter*> NodeMap;
+  typedef std::map<std::string, Prefilter*> NodeMap;
 
   // Each unique node has a corresponding Entry that helps in
   // passing the matching trigger information along the tree.
@@ -90,7 +90,7 @@
   // This function assigns unique ids to various parts of the
   // prefilter, by looking at if these nodes are already in the
   // PrefilterTree.
-  void AssignUniqueIds(NodeMap* nodes, std::vector<string>* atom_vec);
+  void AssignUniqueIds(NodeMap* nodes, std::vector<std::string>* atom_vec);
 
   // Given the matching atoms, find the regexps to be triggered.
   void PropagateMatch(const std::vector<int>& atom_ids,
@@ -102,10 +102,10 @@
 
   // A string that uniquely identifies the node. Assumes that the
   // children of node has already been assigned unique ids.
-  string NodeString(Prefilter* node) const;
+  std::string NodeString(Prefilter* node) const;
 
   // Recursively constructs a readable prefilter string.
-  string DebugNodeString(Prefilter* node) const;
+  std::string DebugNodeString(Prefilter* node) const;
 
   // Used for debugging.
   void PrintDebugInfo(NodeMap* nodes);