Skip to content

Commit fba48d3

Browse files
committed
Fix reserve counts in irep_hash_container_baset::pack
In 48c40db the *2 got lost, and previously it already was off-by-one, all of which result in unnecessary re-allocations.
1 parent 28ea484 commit fba48d3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/util/irep_hash_container.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ void irep_hash_container_baset::pack(
5252

5353
if(full)
5454
{
55-
packed.reserve(1 + 1 + sub.size() + named_sub.size());
55+
// we pack: the irep id, the sub size, the subs, the named-sub size, and
56+
// each of the named subs with their ids
57+
packed.reserve(1 + 1 + sub.size() + 1 + named_sub.size() * 2);
5658

5759
packed.push_back(irep_id_hash()(irep.id()));
5860

@@ -72,7 +74,9 @@ void irep_hash_container_baset::pack(
7274
const std::size_t non_comment_count =
7375
irept::number_of_non_comments(named_sub);
7476

75-
packed.reserve(1 + 1 + sub.size() + non_comment_count);
77+
// we pack: the irep id, the sub size, the subs, the named-sub size, and
78+
// each of the non-comment named subs with their ids
79+
packed.reserve(1 + 1 + sub.size() + 1 + non_comment_count * 2);
7680

7781
packed.push_back(irep_id_hash()(irep.id()));
7882

0 commit comments

Comments
 (0)