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:
parent
cd378d16e3
commit
fe01f50c65
7 changed files with 8 additions and 16 deletions
|
@ -123,7 +123,7 @@ class BdistAPK(Command):
|
||||||
exit(1)
|
exit(1)
|
||||||
if len(main_py_dirs) > 1:
|
if len(main_py_dirs) > 1:
|
||||||
print('WARNING: Multiple main.py dirs found, using the shortest path')
|
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'):
|
if not argv_contains('--launcher'):
|
||||||
sys.argv.append('--private={}'.format(
|
sys.argv.append('--private={}'.format(
|
||||||
|
@ -145,4 +145,4 @@ def _set_user_options():
|
||||||
|
|
||||||
BdistAPK.user_options = user_options
|
BdistAPK.user_options = user_options
|
||||||
|
|
||||||
_set_user_options()
|
_set_user_options()
|
||||||
|
|
|
@ -447,8 +447,7 @@ main.py that loads it.''')
|
||||||
# Try to build with the newest available build tools
|
# Try to build with the newest available build tools
|
||||||
ignored = {".DS_Store", ".ds_store"}
|
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 = [x for x in listdir(join(sdk_dir, 'build-tools')) if x not in ignored]
|
||||||
build_tools_versions = sorted(build_tools_versions,
|
build_tools_versions.sort(key=LooseVersion)
|
||||||
key=LooseVersion)
|
|
||||||
build_tools_version = build_tools_versions[-1]
|
build_tools_version = build_tools_versions[-1]
|
||||||
|
|
||||||
# Folder name for launcher (used by SDL2 bootstrap)
|
# Folder name for launcher (used by SDL2 bootstrap)
|
||||||
|
|
|
@ -344,8 +344,7 @@ main.py that loads it.''')
|
||||||
|
|
||||||
# Try to build with the newest available build tools
|
# Try to build with the newest available build tools
|
||||||
build_tools_versions = listdir(join(sdk_dir, 'build-tools'))
|
build_tools_versions = listdir(join(sdk_dir, 'build-tools'))
|
||||||
build_tools_versions = sorted(build_tools_versions,
|
build_tools_versions.sort(key=LooseVersion)
|
||||||
key=LooseVersion)
|
|
||||||
build_tools_version = build_tools_versions[-1]
|
build_tools_version = build_tools_versions[-1]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -293,8 +293,7 @@ def get_recipe_order_and_bootstrap(ctx, names, bs=None, blacklist=None):
|
||||||
orders.append(list(order))
|
orders.append(list(order))
|
||||||
|
|
||||||
# prefer python3 and SDL2 if available
|
# prefer python3 and SDL2 if available
|
||||||
orders = sorted(orders,
|
orders.sort(key=lambda order: -('python3' in order) - ('sdl2' in order))
|
||||||
key=lambda order: -('python3' in order) - ('sdl2' in order))
|
|
||||||
|
|
||||||
if not orders:
|
if not orders:
|
||||||
raise BuildInterruptingException(
|
raise BuildInterruptingException(
|
||||||
|
|
|
@ -93,9 +93,7 @@ def find_channel(force=False):
|
||||||
if not force:
|
if not force:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
busy.sort(key=lambda x: x.play_time)
|
return min(busy, key=lambda x: x.play_time)
|
||||||
|
|
||||||
return busy[0]
|
|
||||||
|
|
||||||
|
|
||||||
class ChannelImpl(object):
|
class ChannelImpl(object):
|
||||||
|
|
|
@ -822,8 +822,7 @@ class ToolchainCL(object):
|
||||||
|
|
||||||
build_tools_versions = os.listdir(join(ctx.sdk_dir,
|
build_tools_versions = os.listdir(join(ctx.sdk_dir,
|
||||||
'build-tools'))
|
'build-tools'))
|
||||||
build_tools_versions = sorted(build_tools_versions,
|
build_tools_versions.sort(key=LooseVersion)
|
||||||
key=LooseVersion)
|
|
||||||
build_tools_version = build_tools_versions[-1]
|
build_tools_version = build_tools_versions[-1]
|
||||||
info(('Detected highest available build tools '
|
info(('Detected highest available build tools '
|
||||||
'version to be {}').format(build_tools_version))
|
'version to be {}').format(build_tools_version))
|
||||||
|
|
|
@ -79,9 +79,7 @@ def find_channel(force=False):
|
||||||
if not force:
|
if not force:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
busy.sort(key=lambda x : x.play_time)
|
return min(busy, key=lambda x : x.play_time)
|
||||||
|
|
||||||
return busy[0]
|
|
||||||
|
|
||||||
class ChannelImpl(object):
|
class ChannelImpl(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue