From 28ea4840e9425ce56ce146d80097c74d040e4bba Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 20 Dec 2018 12:04:43 +0000 Subject: [PATCH 1/4] Add missing include Since a1c6e54e uses std::map, but the header was only provided through irep.h, which might not do so in case SUB_IS_LIST is in effect. --- src/util/format_expr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/format_expr.cpp b/src/util/format_expr.cpp index 35c9e828749..d89ebc6151b 100644 --- a/src/util/format_expr.cpp +++ b/src/util/format_expr.cpp @@ -27,6 +27,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "string2int.h" #include "string_utils.h" +#include #include #include From fba48d39fe6df6f8d6a24cc7b4e15799b4cff7af Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 20 Dec 2018 12:10:33 +0000 Subject: [PATCH 2/4] Fix reserve counts in irep_hash_container_baset::pack In 48c40db564b1a the *2 got lost, and previously it already was off-by-one, all of which result in unnecessary re-allocations. --- src/util/irep_hash_container.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/irep_hash_container.cpp b/src/util/irep_hash_container.cpp index ee8bc99d90c..bb88e0ae001 100644 --- a/src/util/irep_hash_container.cpp +++ b/src/util/irep_hash_container.cpp @@ -52,7 +52,9 @@ void irep_hash_container_baset::pack( if(full) { - packed.reserve(1 + 1 + sub.size() + named_sub.size()); + // we pack: the irep id, the sub size, the subs, the named-sub size, and + // each of the named subs with their ids + packed.reserve(1 + 1 + sub.size() + 1 + named_sub.size() * 2); packed.push_back(irep_id_hash()(irep.id())); @@ -72,7 +74,9 @@ void irep_hash_container_baset::pack( const std::size_t non_comment_count = irept::number_of_non_comments(named_sub); - packed.reserve(1 + 1 + sub.size() + non_comment_count); + // we pack: the irep id, the sub size, the subs, the named-sub size, and + // each of the non-comment named subs with their ids + packed.reserve(1 + 1 + sub.size() + 1 + non_comment_count * 2); packed.push_back(irep_id_hash()(irep.id())); From 300733238e5094608f73b642b24e297f0b0d8b0a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 20 Dec 2018 12:36:01 +0000 Subject: [PATCH 3/4] Fix to_be_merged_irept::operator== This returned the wrong value in case sub/named_sub had mismatching size. It really was wrong ever since committed to the repository, proving that the code never was used. It should likely just be removed. --- src/util/merge_irep.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/merge_irep.cpp b/src/util/merge_irep.cpp index db4df77d74e..ae6d7d3e16b 100644 --- a/src/util/merge_irep.cpp +++ b/src/util/merge_irep.cpp @@ -44,9 +44,9 @@ bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const const irept::named_subt &o_named_sub=other.get_named_sub(); if(sub.size()!=o_sub.size()) - return true; + return false; if(named_sub.size()!=o_named_sub.size()) - return true; + return false; { irept::subt::const_iterator s_it=sub.begin(); From d4649bcd256cb8ed8b4a055be85dd033902efa16 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 20 Dec 2018 12:37:39 +0000 Subject: [PATCH 4/4] merge_(full_)irept: Move the newly created irept There is no need to create a copy at this point. --- src/util/merge_irep.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/merge_irep.cpp b/src/util/merge_irep.cpp index ae6d7d3e16b..7937adb29cf 100644 --- a/src/util/merge_irep.cpp +++ b/src/util/merge_irep.cpp @@ -148,7 +148,7 @@ const irept &merge_irept::merged(const irept &irep) dest_named_sub[it->first]=merged(it->second); // recursive call #endif - return *irep_store.insert(new_irep).first; + return *irep_store.insert(std::move(new_irep)).first; } void merge_full_irept::operator()(irept &irep) @@ -185,5 +185,5 @@ const irept &merge_full_irept::merged(const irept &irep) dest_named_sub[it->first]=merged(it->second); // recursive call #endif - return *irep_store.insert(new_irep).first; + return *irep_store.insert(std::move(new_irep)).first; }