From e75ee0ecf1210d74bdfde2acd57a4aea165e3ad0 Mon Sep 17 00:00:00 2001 From: Michka Popoff Date: Thu, 13 Feb 2025 22:53:17 +0100 Subject: [PATCH] container traits: remove normalisation These were added before the big refactoring around templates. The space issues have been solved since then, and these extra normalisations are not necessary anymore I just added them at one point to be able to fix some tests and get a better visibility This should slightly improve performance as we remove an unnecessary operation --- src/pygccxml/declarations/container_traits.py | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pygccxml/declarations/container_traits.py b/src/pygccxml/declarations/container_traits.py index 00463e57..6e29022d 100644 --- a/src/pygccxml/declarations/container_traits.py +++ b/src/pygccxml/declarations/container_traits.py @@ -110,8 +110,7 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'): container=c_name, value_type=value_type, allocator=default_allocator) - if self.normalize(cls_name) == \ - self.normalize(tmpl): + if cls_name == tmpl: return templates.join( c_name, [self.erase_recursive(value_type)]) @@ -122,8 +121,8 @@ def erase_container(self, cls_name, default_container_name='std::deque'): return value_type = c_args[0] dc_no_defaults = self.erase_recursive(c_args[1]) - if self.normalize(dc_no_defaults) == self.normalize( - templates.join(default_container_name, [value_type])): + if dc_no_defaults == \ + templates.join(default_container_name, [value_type]): return templates.join( c_name, [self.erase_recursive(value_type)]) @@ -137,12 +136,12 @@ def erase_container_compare( if len(c_args) != 3: return dc_no_defaults = self.erase_recursive(c_args[1]) - if self.normalize(dc_no_defaults) != self.normalize( - templates.join(default_container_name, [c_args[0]])): + if dc_no_defaults != \ + templates.join(default_container_name, [c_args[0]]): return dcomp_no_defaults = self.erase_recursive(c_args[2]) - if self.normalize(dcomp_no_defaults) != self.normalize( - templates.join(default_compare, [c_args[0]])): + if dcomp_no_defaults != \ + templates.join(default_compare, [c_args[0]]): return value_type = self.erase_recursive(c_args[0]) return templates.join(c_name, [value_type]) @@ -165,8 +164,7 @@ def erase_compare_allocator( value_type=value_type, compare=default_compare, allocator=default_allocator) - if self.normalize(cls_name) == \ - self.normalize(tmpl): + if cls_name == tmpl: return templates.join( c_name, [self.erase_recursive(value_type)]) @@ -198,7 +196,7 @@ def erase_map_compare_allocator( mapped_type=mapped_type, compare=default_compare, allocator=default_allocator) - if self.normalize(cls_name) == self.normalize(tmpl): + if cls_name == tmpl: return templates.join( c_name, [self.erase_recursive(key_type), @@ -237,8 +235,7 @@ def erase_hash_allocator(self, cls_name): less=default_less, equal_to=default_equal_to, allocator=default_allocator) - if self.normalize(cls_name) == \ - self.normalize(inst): + if cls_name == inst: return templates.join( c_name, [self.erase_recursive(value_type)]) @@ -316,7 +313,7 @@ def erase_hashmap_compare_allocator(self, cls_name): equal_to=default_equal_to, allocator=default_allocator) - if self.normalize(cls_name) == self.normalize(inst): + if cls_name == inst: return templates.join( c_name, [self.erase_recursive(key_type),