intel/genxml: use a set for lookups
authorDylan Baker <dylan.c.baker@intel.com>
Fri, 30 Sep 2022 17:59:15 +0000 (10:59 -0700)
committerDylan Baker <dylan.c.baker@intel.com>
Sat, 1 Oct 2022 21:03:49 +0000 (14:03 -0700)
Python will pre-compute the set since it's const, and the performance of
a set search is significantly better than that of a list search

Reviewd-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18917>

src/intel/genxml/gen_sort_tags.py

index bcb051d..cab59f9 100755 (executable)
@@ -21,19 +21,19 @@ def get_start(element):
     return int(element.attrib['start'], 0)
 
 
-base_types = [
+BASE_TYPES = {
     'address',
     'offset',
     'int',
     'uint',
     'bool',
     'float',
-]
+}
 
 FIXED_PATTERN = re.compile(r"(s|u)(\d+)\.(\d+)")
 
 def is_base_type(name):
-    return name in base_types or FIXED_PATTERN.match(name)
+    return name in BASE_TYPES or FIXED_PATTERN.match(name)
 
 def add_struct_refs(items, node):
     if node.tag == 'field':