Skip to content

Commit 18b1e63

Browse files
authored
More usage of utils.removeprefix. NFC (#25893)
1 parent c6f9259 commit 18b1e63

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

tools/building.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,10 +886,9 @@ def metadce(js_file, wasm_file, debug_info, last):
886886
# find the unused things in js
887887
unused_imports = []
888888
unused_exports = []
889-
PREFIX = 'unused: '
890889
for line in out.splitlines():
891-
if line.startswith(PREFIX):
892-
name = line.replace(PREFIX, '').strip()
890+
if line.startswith('unused:'):
891+
name = line.removeprefix('unused:').strip()
893892
# With dynamic linking we never want to strip the memory or the table
894893
# This can be removed once SIDE_MODULE_IMPORTS includes tables and memories.
895894
if settings.MAIN_MODULE and name.split('$')[-1] in ('wasmMemory', 'wasmTable'):

tools/diagnostics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def capture_warnings(self, cmd_args):
9898
cmd_args[i] = ''
9999
continue
100100

101-
warning_name = cmd_args[i].replace('-Wno-', '').replace('-W', '')
101+
warning_name = cmd_args[i].removeprefix('-Wno-').removeprefix('-W')
102102
enabled = not cmd_args[i].startswith('-Wno-')
103103

104104
# special case pre-existing warn-absolute-paths

tools/emscripten.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ def create_receiving(function_exports, other_exports, library_symbols, aliases):
911911
receiving.append(' // Construct dynCalls mapping')
912912
for sym in function_exports:
913913
if sym.startswith('dynCall_'):
914-
sig_str = sym.replace('dynCall_', '')
914+
sig_str = sym.removeprefix('dynCall_')
915915
receiving.append(f" dynCalls['{sig_str}'] = {sym};")
916916
receiving.append('}')
917917

@@ -968,7 +968,7 @@ def create_receiving(function_exports, other_exports, library_symbols, aliases):
968968
mangled = asmjs_mangle(sym)
969969
assignment = mangled
970970
if generate_dyncall_assignment and is_function and sym.startswith('dynCall_'):
971-
sig_str = sym.replace('dynCall_', '')
971+
sig_str = sym.removeprefix('dynCall_')
972972
assignment += f" = dynCalls['{sig_str}']"
973973
if do_module_exports and should_export(mangled):
974974
assignment += f" = Module['{mangled}']"

tools/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def env_with_node_in_path():
279279

280280
def _get_node_version_pair(nodejs):
281281
actual = utils.run_process(nodejs + ['--version'], stdout=PIPE).stdout.strip()
282-
version = actual.replace('v', '')
282+
version = actual.removeprefix('v')
283283
version = version.split('-')[0].split('.')
284284
version = tuple(int(v) for v in version)
285285
return actual, version

0 commit comments

Comments
 (0)