Skip to content

Commit

Permalink
container traits: remove normalisation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
iMichka committed Feb 13, 2025
1 parent c98759f commit e75ee0e
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/pygccxml/declarations/container_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])

Expand All @@ -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)])

Expand All @@ -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])
Expand All @@ -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)])

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)])

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit e75ee0e

Please sign in to comment.