diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-29 15:39:34 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-31 16:03:58 -0700 |
commit | 766c6e1e76e25aea933086e73587cd103a85f9d0 (patch) | |
tree | 973de73f3cad1fd33e4d72aee9146f609ef18976 | |
parent | b0bd3cb64ebb1799efcfc5eca297b77b36479965 (diff) |
glapi: gl_XML.py: rework gl_api.functionIterateByOffset
This reworks this method to use the sorted() built-in rather than taking
the dictionary keys (which involves creating a brand new copy of the
list in memory), sorting it, then iterating the new sorted list and
doing a lookup into the dictionary. Then it does away with building a
list and returning an iterator over that list, instead using an
efficient generator to yield each item one at a time.
The resulting function is less code, commented, and should be a little
more efficient.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | src/mapi/glapi/gen/gl_XML.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 91f10910aa..334fd6e683 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -919,20 +919,12 @@ class gl_api(object): func_cat_type, key = classify_category(cat_name, cat_number) lists[func_cat_type][key][func.name] = func - - functions = [] - for func_cat_type in range(4): - keys = lists[func_cat_type].keys() - keys.sort() - - for key in keys: - names = lists[func_cat_type][key].keys() - names.sort() - - for name in names: - functions.append(lists[func_cat_type][key][name]) - - return iter(functions) + # This needs to be use {iter}items(), (and thus the _) to be able to + # sort correctly. + for dict_ in lists: + for _, items in sorted(dict_.iteritems()): + for _, function in sorted(items.iteritems()): + yield function def functionIterateByOffset(self): max_offset = max(f.offset for f in self.functions_by_name.itervalues()) |