@@ -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}
@@ -44,9 +50,16 @@ bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const
4450 const irept::named_subt &o_named_sub=other.get_named_sub ();
4551
4652 if (sub.size ()!=o_sub.size ())
47- return true ;
53+ 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+ return false ;
59+ #else
4860 if (named_sub.size ()!=o_named_sub.size ())
49- return true ;
61+ return false ;
62+ #endif
5063
5164 {
5265 irept::subt::const_iterator s_it=sub.begin ();
@@ -95,13 +108,19 @@ const merged_irept &merged_irepst::merged(const irept &irep)
95108 const irept::named_subt &src_named_sub=irep.get_named_sub ();
96109 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
97110
111+ #ifdef SUB_IS_LIST
112+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
113+ #endif
98114 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
115+ {
116+ #ifdef SUB_IS_LIST
117+ dest_named_sub.emplace_after (
118+ before, it->first , merged (it->second )); // recursive call
119+ ++before;
120+ #else
103121 dest_named_sub[it->first ]=merged (it->second ); // recursive call
104- #endif
122+ #endif
123+ }
105124
106125 std::pair<to_be_merged_irep_storet::const_iterator, bool > result=
107126 to_be_merged_irep_store.insert (to_be_merged_irept (new_irep));
@@ -140,13 +159,19 @@ const irept &merge_irept::merged(const irept &irep)
140159 const irept::named_subt &src_named_sub=irep.get_named_sub ();
141160 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
142161
162+ #ifdef SUB_IS_LIST
163+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
164+ #endif
143165 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
166+ {
167+ #ifdef SUB_IS_LIST
168+ dest_named_sub.emplace_after (
169+ before, it->first , merged (it->second )); // recursive call
170+ ++before;
171+ #else
148172 dest_named_sub[it->first ]=merged (it->second ); // recursive call
149- #endif
173+ #endif
174+ }
150175
151176 return *irep_store.insert (new_irep).first ;
152177}
@@ -177,13 +202,19 @@ const irept &merge_full_irept::merged(const irept &irep)
177202 const irept::named_subt &src_named_sub=irep.get_named_sub ();
178203 irept::named_subt &dest_named_sub=new_irep.get_named_sub ();
179204
205+ #ifdef SUB_IS_LIST
206+ irept::named_subt::iterator before = dest_named_sub.before_begin ();
207+ #endif
180208 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
209+ {
210+ #ifdef SUB_IS_LIST
211+ dest_named_sub.emplace_after (
212+ before, it->first , merged (it->second )); // recursive call
213+ ++before;
214+ #else
185215 dest_named_sub[it->first ]=merged (it->second ); // recursive call
186- #endif
216+ #endif
217+ }
187218
188219 return *irep_store.insert (new_irep).first ;
189220}
0 commit comments