[13/14] ir: Use a list for canonical types to speed up additions
Commit Message
Adding a new canonical type to the system involves adding it to a
sequence. Today, that sequence is a vector. It turned out adding 2+
millions of types (when analyzing the Linux kernel) can take a while.
So I am turning this into a list instead. This helps saves quite some
time.
* src/abg-ir-priv.h (compute_canonical_type_index)
(candidate_matches_a_canonical_type_hash): Take a list of
type_base_sptr rather than a vector.
(homonym_type_group::canonical_types_): Make this
a list of type_base_sptr rather than a vector.
* src/abg-ir.cc (candidate_matches_a_canonical_type_hash)
(compute_canonical_type_index): Take a list of type_base_sptr
rather than a vector.
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
---
src/abg-ir-priv.h | 9 +++++----
src/abg-ir.cc | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
@@ -41,6 +41,7 @@ using std::lock_guard;
using std::recursive_mutex;
using std::atomic;
using std::string;
+using std::list;
using std::unordered_set;
using std::ostringstream;
using abg_compat::optional;
@@ -385,7 +386,7 @@ compare_canonical_type_against_candidate(const type_base* canonical_type,
const type_base* candidate_type);
bool
-compute_canonical_type_index(const vector<type_base_sptr>& adjacent_canonical_types,
+compute_canonical_type_index(const list<type_base_sptr>& adjacent_canonical_types,
const type_base_sptr canonical_type,
int& resulting_index);
@@ -398,7 +399,7 @@ maybe_adjust_canonical_type(const type_base_sptr& canonical,
const type_base_sptr& type);
type_base_sptr
-candidate_matches_a_canonical_type_hash(const vector<type_base_sptr>& cncls,
+candidate_matches_a_canonical_type_hash(const list<type_base_sptr>& cncls,
type_base& type);
bool
@@ -654,7 +655,7 @@ class homonym_type_group
// The types of the group.
vector<type_base_sptr> types_;
// The canonical types of the types in types_.
- vector<type_base_sptr> canonical_types_;
+ list<type_base_sptr> canonical_types_;
canonical_type_sptr_set_type canonical_types_set_;
public:
@@ -676,7 +677,7 @@ public:
get_types() const
{return types_;}
- const vector<type_base_sptr>&
+ const list<type_base_sptr>&
get_canonical_types() const
{return canonical_types_;}
@@ -16573,7 +16573,7 @@ compare_canonical_type_against_candidate(const type_base_sptr& canonical_type,
/// @return the canonical type from @p cncls that matches the
/// candidate @p type.
type_base_sptr
-candidate_matches_a_canonical_type_hash(const vector<type_base_sptr>& cncls,
+candidate_matches_a_canonical_type_hash(const list<type_base_sptr>& cncls,
type_base& type)
{
if (type.get_corpus()
@@ -16681,7 +16681,7 @@ type_is_suitable_for_hash_computing(const type_base& t)
/// @return true iff the function could compute the canonical index
/// and set it into @p resulting_index.
bool
-compute_canonical_type_index(const vector<type_base_sptr>& adjacent_canonical_types,
+compute_canonical_type_index(const list<type_base_sptr>& adjacent_canonical_types,
const type_base_sptr canonical_type,
int& resulting_index)
{