summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2016-03-29 15:38:43 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2016-03-31 16:03:58 -0700
commitb0bd3cb64ebb1799efcfc5eca297b77b36479965 (patch)
tree7ed85224c0823e88792044c34c9044bcc61ec90c
parentff24610843dea9a5e98b86ed6be16cda73b07181 (diff)
glapi: gl_XML.py: use collections to simplify functionsIterateByCategory
This uses the collections.defaultdict to remove the need to check and add an empty dict, since defaultdict will call the default factory for us whenever a KeyError would be raised (by a missing key value). Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r--src/mapi/glapi/gen/gl_XML.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index 221bd18a6d..91f10910aa 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -29,6 +29,7 @@
# Ian Romanick <idr@us.ibm.com>
from decimal import Decimal
+import collections
import os.path
import re
import textwrap
@@ -909,17 +910,13 @@ class gl_api(object):
Within a category, functions are sorted by name. If cat is
not None, then only functions in that category are iterated.
"""
- lists = [{}, {}, {}, {}]
+ lists = [collections.defaultdict(lambda: {}) for _ in range(4)]
for func in self.functionIterateAll():
- [cat_name, cat_number] = self.category_dict[func.name]
+ cat_name, cat_number = self.category_dict[func.name]
if cat is None or cat == cat_name:
- [func_cat_type, key] = classify_category(cat_name, cat_number)
-
- if key not in lists[func_cat_type]:
- lists[func_cat_type][key] = {}
-
+ func_cat_type, key = classify_category(cat_name, cat_number)
lists[func_cat_type][key][func.name] = func