[13/14] ir: Use a list for canonical types to speed up additions

Message ID 20260925210608.3532891-14-dodji@seketeli.org
State New
Headers
Series [01/14] kmidiff.rst: Fix some typos in the kmidiff manual |

Commit Message

Dodji Seketeli Sept. 25, 2026, 9:06 p.m. UTC
  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(-)
  

Patch

diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h
index 641ac27d..0196f08c 100644
--- a/src/abg-ir-priv.h
+++ b/src/abg-ir-priv.h
@@ -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_;}
 
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 7828267b..8a5b7035 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -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)
 {