This patch is Reviewed-by: Ian Romanick <[email protected]>
On 03/31/2016 05:04 PM, Dylan Baker wrote: > 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 <[email protected]> > --- > src/mapi/glapi/gen/gl_XML.py | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py > index 221bd18..91f1091 100644 > --- a/src/mapi/glapi/gen/gl_XML.py > +++ b/src/mapi/glapi/gen/gl_XML.py > @@ -29,6 +29,7 @@ > # Ian Romanick <[email protected]> > > 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 > > > _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
