mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
Remove unneeded dict sorting functions in CodegenRust.py
This commit is contained in:
parent
f4a2fe9501
commit
d63c9d79d3
1 changed files with 4 additions and 18 deletions
|
@ -1983,23 +1983,6 @@ def getAllTypes(descriptors, dictionaries, callbacks):
|
|||
yield (t, None, None)
|
||||
|
||||
|
||||
def SortedTuples(l):
|
||||
"""
|
||||
Sort a list of tuples based on the first item in the tuple
|
||||
"""
|
||||
return sorted(l, key=operator.itemgetter(0))
|
||||
|
||||
|
||||
def SortedDictValues(d):
|
||||
"""
|
||||
Returns a list of values from the dict sorted by key.
|
||||
"""
|
||||
# Create a list of tuples containing key and value, sorted on key.
|
||||
d = SortedTuples(d.items())
|
||||
# We're only interested in the values.
|
||||
return (i[1] for i in d)
|
||||
|
||||
|
||||
def UnionTypes(descriptors, dictionaries, callbacks, config):
|
||||
"""
|
||||
Returns a CGList containing CGUnionStructs for every union.
|
||||
|
@ -2038,7 +2021,10 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
|
|||
CGUnionConversionStruct(t, provider)
|
||||
])
|
||||
|
||||
return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], [], imports, ignored_warnings=[])
|
||||
# Sort unionStructs by key, retrieve value
|
||||
unionStructs = (i[1] for i in sorted(unionStructs.items(), key=operator.itemgetter(0)))
|
||||
|
||||
return CGImports(CGList(unionStructs, "\n\n"), [], [], imports, ignored_warnings=[])
|
||||
|
||||
|
||||
class Argument():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue