]> sourceware.org Git - systemtap.git/commitdiff
PR11528: embedded_tags_visitor store tags in a set
authorAbegail Jakop <ajakop@redhat.com>
Mon, 6 Oct 2014 21:03:25 +0000 (17:03 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Mon, 6 Oct 2014 21:03:25 +0000 (17:03 -0400)
staptree.cxx
staptree.h
translate.cxx

index e04bbaa0bee49a38f2eaa3db64132a234cda4921..d3fc53aacb67a938dc6826895da9bcdd7c2f51d0 100644 (file)
@@ -573,23 +573,29 @@ void functiondecl::printsig (ostream& o) const
 
 embedded_tags_visitor::embedded_tags_visitor(bool all_tags)
 {
-  tags["/* guru */"] = false;
-  tags["/* unprivileged */"] = false;
-  tags["/* myproc-unprivileged */"] = false;
+  // populate the set of tags that could appear in embedded code/expressions
+  available_tags.insert("/* guru */");
+  available_tags.insert("/* unprivileged */");
+  available_tags.insert("/* myproc-unprivileged */");
   if (all_tags)
     {
-      tags["/* pure */"] = false;
-      tags["/* unmangled */"] = false;
-      tags["/* unmodified-fnargs */"] = false;
+      available_tags.insert("/* pure */");
+      available_tags.insert("/* unmangled */");
+      available_tags.insert("/* unmodified-fnargs */");
     }
 }
 
+bool embedded_tags_visitor::tagged_p (const std::string& tag)
+{
+  return tags.count(tag);
+}
+
 void embedded_tags_visitor::find_tags_in_code (const string& s)
 {
-  map<string, bool>::iterator tag;
-  for (tag = tags.begin(); tag != tags.end(); ++tag)
-    if (!tag->second)
-      tag->second = s.find(tag->first) != string::npos;
+  set<string>::iterator tag;
+  for (tag = available_tags.begin(); tag != available_tags.end(); ++tag)
+      if(s.find(*tag) != string::npos)
+        tags.insert(*tag);
 }
 
 void embedded_tags_visitor::visit_embeddedcode (embeddedcode *s)
@@ -611,10 +617,10 @@ void functiondecl::printsigtags (ostream& o, bool all_tags) const
   embedded_tags_visitor etv(all_tags);
   this->body->visit(&etv);
 
-  map<string, bool>::const_iterator tag;
-  for (tag = etv.tags.begin(); tag != etv.tags.end(); ++tag)
-    if (tag->second)
-      o << " " << tag->first;
+  set<string, bool>::const_iterator tag;
+  for (tag = etv.available_tags.begin(); tag != etv.available_tags.end(); ++tag)
+    if (etv.tagged_p(*tag))
+      o << " " << *tag;
 }
 
 void arrayindex::print (ostream& o) const
index 1ad4e91a7757851e15c671bea54a0af6a7dece25..f27b8c9da4d6c6416707afe93e78d6f1fe2e56c6 100644 (file)
@@ -1238,8 +1238,10 @@ struct deep_copy_visitor: public update_visitor
 
 struct embedded_tags_visitor: public traversing_visitor
 {
-  std::map<std::string, bool> tags;
+  std::set<std::string> available_tags;
+  std::set<std::string> tags; // set of the tags that appear in the code
   embedded_tags_visitor(bool all_tags);
+  bool tagged_p (const std::string &tag);
   void find_tags_in_code (const std::string& s);
   void visit_embeddedcode (embeddedcode *s);
   void visit_embedded_expr (embedded_expr *e);
index 204c0f7778c86277529904dc3d7e456c0b54887a..223a3c532932447daaa619893a784e0ed6f706be 100644 (file)
@@ -943,7 +943,7 @@ struct unmodified_fnargs_checker : public embedded_tags_visitor
     {
       embedded_tags_visitor::visit_embeddedcode(e);
       // set embedded_seen to true if it does not contain /* unmodified-fnargs */
-      embedded_seen = (embedded_seen || !tags.find("/* unmodified-fnargs */")->second);
+      embedded_seen = (embedded_seen || !tagged_p("/* unmodified-fnargs */"));
     }
 };
 
This page took 0.042998 seconds and 5 git commands to generate.