@@ -28,7 +28,13 @@ std::size_t to_be_merged_irept::hash() const
2828 result, static_cast <const merged_irept &>(it->second ).hash ());
2929 }
3030
31- result=hash_finalize (result, named_sub.size ()+sub.size ());
31+ #ifdef SUB_IS_LIST
32+ const std::size_t named_sub_size =
33+ std::distance (named_sub.begin (), named_sub.end ());
34+ #else
35+ const std::size_t named_sub_size = named_sub.size ();
36+ #endif
37+ result = hash_finalize (result, named_sub_size + sub.size ());
3238
3339 return result;
3440}
@@ -45,8 +51,17 @@ bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const
4551
4652 if (sub.size ()!=o_sub.size ())
4753 return false ;
54+ #ifdef SUB_IS_LIST
55+ if (
56+ std::distance (named_sub.begin (), named_sub.end ()) !=
57+ std::distance (o_named_sub.begin (), o_named_sub.end ()))
58+ {
59+ return false ;
60+ }
61+ #else
4862 if (named_sub.size ()!=o_named_sub.size ())
4963 return false ;
64+ #endif
5065
5166 {
5267 irept::subt::const_iterator s_it=sub.begin ();
@@ -95,13 +110,19 @@ const merged_irept &merged_irepst::merged(const irept &irep)
95110 const irept::named_subt &src_named_sub=irep.get_named_sub ();
96111 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
97112
113+ #ifdef SUB_IS_LIST
114+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
115+ #endif
98116 forall_named_irep (it, src_named_sub)
99- #ifdef SUB_IS_LIST
100- dest_named_sub.push_back (
101- std::make_pair (it->first , merged (it->second ))); // recursive call
102- #else
117+ {
118+ #ifdef SUB_IS_LIST
119+ dest_named_sub.emplace_after (
120+ before, it->first , merged (it->second )); // recursive call
121+ ++before;
122+ #else
103123 dest_named_sub[it->first ]=merged (it->second ); // recursive call
104- #endif
124+ #endif
125+ }
105126
106127 std::pair<to_be_merged_irep_storet::const_iterator, bool > result=
107128 to_be_merged_irep_store.insert (to_be_merged_irept (new_irep));
@@ -140,13 +161,19 @@ const irept &merge_irept::merged(const irept &irep)
140161 const irept::named_subt &src_named_sub=irep.get_named_sub ();
141162 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
142163
164+ #ifdef SUB_IS_LIST
165+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
166+ #endif
143167 forall_named_irep (it, src_named_sub)
144- #ifdef SUB_IS_LIST
145- dest_named_sub.push_back (
146- std::make_pair (it->first , merged (it->second ))); // recursive call
147- #else
168+ {
169+ #ifdef SUB_IS_LIST
170+ dest_named_sub.emplace_after (
171+ before, it->first , merged (it->second )); // recursive call
172+ ++before;
173+ #else
148174 dest_named_sub[it->first ]=merged (it->second ); // recursive call
149- #endif
175+ #endif
176+ }
150177
151178 return *irep_store.insert (std::move (new_irep)).first ;
152179}
@@ -177,13 +204,19 @@ const irept &merge_full_irept::merged(const irept &irep)
177204 const irept::named_subt &src_named_sub=irep.get_named_sub ();
178205 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
179206
207+ #ifdef SUB_IS_LIST
208+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
209+ #endif
180210 forall_named_irep (it, src_named_sub)
181- #ifdef SUB_IS_LIST
182- dest_named_sub.push_back (
183- std::make_pair (it->first , merged (it->second ))); // recursive call
184- #else
211+ {
212+ #ifdef SUB_IS_LIST
213+ dest_named_sub.emplace_after (
214+ before, it->first , merged (it->second )); // recursive call
215+ ++before;
216+ #else
185217 dest_named_sub[it->first ]=merged (it->second ); // recursive call
186- #endif
218+ #endif
219+ }
187220
188221 return *irep_store.insert (std::move (new_irep)).first ;
189222}
0 commit comments