summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-08-09 10:27:24 +0200
committerDylan Baker <[email protected]>2018-08-09 16:49:19 -0700
commit08fe9b3e3a5bd18db39daa56ecae3fc1a0708ff5 (patch)
treee2148064b1f6b522049e59ab18475a97f241f1a2
parent8d3ff6244c7cc5a8399afcf0d1d98d7fd8148452 (diff)
python: Simplify list sorting
Instead of copying the list, then sorting the copy in-place, we can just get a new sorted copy directly. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
-rw-r--r--src/mapi/mapi_abi.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
index d4c48ec4300..dc48fa5935f 100644
--- a/src/mapi/mapi_abi.py
+++ b/src/mapi/mapi_abi.py
@@ -291,8 +291,7 @@ class ABIPrinter(object):
self.entries = entries
# sort entries by their names
- self.entries_sorted_by_names = self.entries[:]
- self.entries_sorted_by_names.sort(key=attrgetter('name'))
+ self.entries_sorted_by_names = sorted(self.entries, key=attrgetter('name'))
self.indent = ' ' * 3
self.noop_warn = 'noop_warn'
@@ -441,8 +440,7 @@ class ABIPrinter(object):
def c_stub_string_pool(self):
"""Return the string pool for use by stubs."""
# sort entries by their names
- sorted_entries = self.entries[:]
- sorted_entries.sort(key=attrgetter('name'))
+ sorted_entries = sorted(self.entries, key=attrgetter('name'))
pool = []
offsets = {}