From: Frank Ch. Eigler Date: Mon, 11 Feb 2019 00:47:19 +0000 (-0500) Subject: fix embedded-c tag memoization thinko X-Git-Tag: release-4.1~101 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=d6b529c432f440de59088bc69237856cc594979b;p=systemtap.git fix embedded-c tag memoization thinko The memoization needs to track both haystack and needle to compute & cache the appropriate result. Much badness happens without. --- diff --git a/staptree.cxx b/staptree.cxx index ff3e7fee4..8ede9e610 100644 --- a/staptree.cxx +++ b/staptree.cxx @@ -349,15 +349,15 @@ string atvar_op::sym_name () // results. bool memo_tagged_p (const interned_string& haystack, const string& needle) { - static map string_find_memoized; + static map ,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; }