File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -61,10 +61,41 @@ void graphml_witnesst::remove_l0_l1(exprt &expr)
61
61
remove_l0_l1 (*it);
62
62
}
63
63
64
+ template <typename T>
65
+ inline void hash_combine (std::size_t &seed, const T &v)
66
+ {
67
+ std::hash<T> hasher;
68
+ seed ^= hasher (v) + 0x9e3779b9 + (seed << 6 ) + (seed >> 2 );
69
+ }
70
+
71
+ namespace std
72
+ {
73
+ template <typename S, typename T>
74
+ struct hash <pair<S, T>>
75
+ {
76
+ inline size_t operator ()(const pair<S, T> &v) const
77
+ {
78
+ size_t seed = 0 ;
79
+ ::hash_combine (seed, v.first);
80
+ ::hash_combine (seed, v.second);
81
+ return seed;
82
+ }
83
+ };
84
+ } // namespace std
85
+
64
86
std::string graphml_witnesst::convert_assign_rec (
65
87
const irep_idt &identifier,
66
88
const code_assignt &assign)
67
89
{
90
+ static std::
91
+ unordered_map<std::pair<unsigned int , const irept::dt *>, std::string>
92
+ cache;
93
+ {
94
+ const auto cit = cache.find ({identifier.get_no (), &assign.read ()});
95
+ if (cit != cache.end ())
96
+ return cit->second ;
97
+ }
98
+
68
99
std::string result;
69
100
70
101
if (assign.rhs ().id () == ID_array_list)
@@ -195,6 +226,7 @@ std::string graphml_witnesst::convert_assign_rec(
195
226
result = lhs + " = " + expr_to_string (ns, identifier, clean_rhs) + " ;" ;
196
227
}
197
228
229
+ cache.insert ({{identifier.get_no (), &assign.read ()}, result});
198
230
return result;
199
231
}
200
232
You can’t perform that action at this time.
0 commit comments