]> sourceware.org Git - systemtap.git/commitdiff
fix embedded-c tag memoization thinko
authorFrank Ch. Eigler <fche@redhat.com>
Mon, 11 Feb 2019 00:47:19 +0000 (19:47 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Mon, 11 Feb 2019 00:47:19 +0000 (19:47 -0500)
The memoization needs to track both haystack and needle to compute &
cache the appropriate result.  Much badness happens without.

staptree.cxx

index ff3e7fee4fefc65fa9596faddb5caa7fd19e7899..8ede9e6109719c1f814abcd8f2b1d3d23c89dc22 100644 (file)
@@ -349,15 +349,15 @@ string atvar_op::sym_name ()
 // results.
 bool memo_tagged_p (const interned_string& haystack, const string& needle)
 {
-  static map <interned_string,bool> string_find_memoized;
+  static map <pair<interned_string,string>,bool> string_find_memoized;
 
-  auto it = string_find_memoized.find(haystack);
+  auto it = string_find_memoized.find(make_pair(haystack,needle));
   if (it != string_find_memoized.end())
     return it->second;
 
   auto findres = haystack.find(needle);
   bool res = (findres != interned_string::npos);
-  string_find_memoized.insert(make_pair(haystack,res));
+  string_find_memoized.insert(make_pair(make_pair(haystack,needle),res));
   
   return res;
 }
This page took 0.028769 seconds and 5 git commands to generate.