Perf: Use of sort and sorted functions optimized (#748)

* Update mixer.py
* Update graph.py
* Update mixer.py
* Update mixer.py
* Update bdistapk.py
* Update toolchain.py
* Update build.py
* Update build.py
This commit is contained in:
g1tman 2019-11-25 15:58:16 +05:30 committed by Akinwale Ariwodola
parent cd378d16e3
commit fe01f50c65
7 changed files with 8 additions and 16 deletions

View file

@ -123,7 +123,7 @@ class BdistAPK(Command):
exit(1)
if len(main_py_dirs) > 1:
print('WARNING: Multiple main.py dirs found, using the shortest path')
main_py_dirs = sorted(main_py_dirs, key=lambda j: len(split(j)))
main_py_dirs.sort(key=lambda j: len(split(j)))
if not argv_contains('--launcher'):
sys.argv.append('--private={}'.format(

View file

@ -447,8 +447,7 @@ main.py that loads it.''')
# Try to build with the newest available build tools
ignored = {".DS_Store", ".ds_store"}
build_tools_versions = [x for x in listdir(join(sdk_dir, 'build-tools')) if x not in ignored]
build_tools_versions = sorted(build_tools_versions,
key=LooseVersion)
build_tools_versions.sort(key=LooseVersion)
build_tools_version = build_tools_versions[-1]
# Folder name for launcher (used by SDL2 bootstrap)

View file

@ -344,8 +344,7 @@ main.py that loads it.''')
# Try to build with the newest available build tools
build_tools_versions = listdir(join(sdk_dir, 'build-tools'))
build_tools_versions = sorted(build_tools_versions,
key=LooseVersion)
build_tools_versions.sort(key=LooseVersion)
build_tools_version = build_tools_versions[-1]

View file

@ -293,8 +293,7 @@ def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None):
orders.append(list(order))
# prefer python3 and SDL2 if available
orders = sorted(orders,
key=lambda order: -('python3' in order) - ('sdl2' in order))
orders.sort(key=lambda order: -('python3' in order) - ('sdl2' in order))
if not orders:
raise BuildInterruptingException(

View file

@ -93,9 +93,7 @@ def find_channel(force=False):
if not force:
return None
busy.sort(key=lambda x: x.play_time)
return busy[0]
return min(busy, key=lambda x: x.play_time)
class ChannelImpl(object):

View file

@ -822,8 +822,7 @@ class ToolchainCL(object):
build_tools_versions = os.listdir(join(ctx.sdk_dir,
'build-tools'))
build_tools_versions = sorted(build_tools_versions,
key=LooseVersion)
build_tools_versions.sort(key=LooseVersion)
build_tools_version = build_tools_versions[-1]
info(('Detected highest available build tools '
'version to be {}').format(build_tools_version))

View file

@ -79,9 +79,7 @@ def find_channel(force=False):
if not force:
return None
busy.sort(key=lambda x : x.play_time)
return busy[0]
return min(busy, key=lambda x : x.play_time)
class ChannelImpl(object):