File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ Author: Daniel Kroening
18
18
#include < util/pointer_predicates.h>
19
19
#include < util/prefix.h>
20
20
#include < util/ssa_expr.h>
21
+ #include < util/string_container.h>
21
22
22
23
#include < langapi/language_util.h>
23
24
#include < langapi/mode.h>
@@ -65,6 +66,15 @@ std::string graphml_witnesst::convert_assign_rec(
65
66
const irep_idt &identifier,
66
67
const code_assignt &assign)
67
68
{
69
+ #ifdef USE_DSTRING
70
+ const auto cit = cache.find ({identifier.get_no (), &assign.read ()});
71
+ #else
72
+ const auto cit =
73
+ cache.find ({get_string_container ()[id2string (identifier)], &assign.read ()});
74
+ #endif
75
+ if (cit != cache.end ())
76
+ return cit->second ;
77
+
68
78
std::string result;
69
79
70
80
if (assign.rhs ().id () == ID_array_list)
@@ -197,6 +207,12 @@ std::string graphml_witnesst::convert_assign_rec(
197
207
result = lhs + " = " + expr_to_string (ns, identifier, clean_rhs) + " ;" ;
198
208
}
199
209
210
+ #ifdef USE_DSTRING
211
+ cache.insert ({{identifier.get_no (), &assign.read ()}, result});
212
+ #else
213
+ cache.insert (
214
+ {{get_string_container ()[id2string (identifier)], &assign.read ()}, result});
215
+ #endif
200
216
return result;
201
217
}
202
218
Original file line number Diff line number Diff line change @@ -42,6 +42,30 @@ class graphml_witnesst
42
42
std::string convert_assign_rec (
43
43
const irep_idt &identifier,
44
44
const code_assignt &assign);
45
+
46
+ template <typename T>
47
+ static void hash_combine (std::size_t &seed, const T &v)
48
+ {
49
+ std::hash<T> hasher;
50
+ seed ^= hasher (v) + 0x9e3779b9 + (seed << 6 ) + (seed >> 2 );
51
+ }
52
+
53
+ template <typename S, typename T>
54
+ struct pair_hash // NOLINT(readability/identifiers)
55
+ {
56
+ std::size_t operator ()(const std::pair<S, T> &v) const
57
+ {
58
+ std::size_t seed = 0 ;
59
+ hash_combine (seed, v.first );
60
+ hash_combine (seed, v.second );
61
+ return seed;
62
+ }
63
+ };
64
+ std::unordered_map<
65
+ std::pair<unsigned int , const irept::dt *>,
66
+ std::string,
67
+ pair_hash<unsigned int , const irept::dt *>>
68
+ cache;
45
69
};
46
70
47
71
#endif // CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H
You can’t perform that action at this time.
0 commit comments