Skip to content

Commit 66303da

Browse files
authored
Remove redundant Building.js_optimizer_no_asmjs. NFC. (#11015)
This method was always called with acorn=True so remove this argument and unify with Building.acorn_optimizer.
1 parent c519c19 commit 66303da

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ def repl(m):
25702570

25712571
# Minify the worker.js file in optimized builds
25722572
if (shared.Settings.OPT_LEVEL >= 1 or shared.Settings.SHRINK_LEVEL >= 1) and not shared.Settings.DEBUG_LEVEL:
2573-
minified_worker = shared.Building.js_optimizer_no_asmjs(worker_output, ['minifyWhitespace'], acorn=True, return_output=True)
2573+
minified_worker = shared.Building.acorn_optimizer(worker_output, ['minifyWhitespace'], return_output=True)
25742574
open(worker_output, 'w').write(minified_worker)
25752575

25762576
# Generate the fetch.js worker script for multithreaded emscripten_fetch() support if targeting pthreads.

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ def test_js_optimizer(self):
21482148
expected = [expected]
21492149
expected = [out.replace('\n\n', '\n').replace('\n\n', '\n') for out in expected]
21502150

2151-
acorn = any([p for p in passes if p in ACORN_PASSES])
2151+
acorn = any(p in ACORN_PASSES for p in passes)
21522152

21532153
# test calling optimizer
21542154
if not acorn:

tools/hacky_postprocess_around_closure_limitations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
# Finally, rerun minifier because the above changes may have left redundant whitespaces
5454
open(sys.argv[1], 'w').write(f)
55-
minified = shared.Building.js_optimizer_no_asmjs(sys.argv[1], ['minifyWhitespace'], acorn=True, return_output=True)
55+
minified = shared.Building.acorn_optimizer(sys.argv[1], ['minifyWhitespace'], return_output=True)
5656
open(sys.argv[1], 'w').write(minified)
5757

5858
# optimized_size = len(f)

tools/shared.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,11 +2031,8 @@ def js_optimizer(filename, passes, debug=False, extra_info=None, output_filename
20312031

20322032
# run JS optimizer on some JS, ignoring asm.js contents if any - just run on it all
20332033
@staticmethod
2034-
def js_optimizer_no_asmjs(filename, passes, return_output=False, extra_info=None, acorn=False):
2035-
if not acorn:
2036-
optimizer = path_from_root('tools', 'js-optimizer.js')
2037-
else:
2038-
optimizer = path_from_root('tools', 'acorn-optimizer.js')
2034+
def acorn_optimizer(filename, passes, extra_info=None, return_output=False):
2035+
optimizer = path_from_root('tools', 'acorn-optimizer.js')
20392036
original_filename = filename
20402037
if extra_info is not None:
20412038
temp_files = configuration.get_temp_files()
@@ -2047,22 +2044,17 @@ def js_optimizer_no_asmjs(filename, passes, return_output=False, extra_info=None
20472044
cmd = NODE_JS + [optimizer, filename] + passes
20482045
# Keep JS code comments intact through the acorn optimization pass so that JSDoc comments
20492046
# will be carried over to a later Closure run.
2050-
if acorn and Settings.USE_CLOSURE_COMPILER:
2047+
if Settings.USE_CLOSURE_COMPILER:
20512048
cmd += ['--closureFriendly']
20522049
if not return_output:
20532050
next = original_filename + '.jso.js'
20542051
configuration.get_temp_files().note(next)
20552052
check_call(cmd, stdout=open(next, 'w'))
20562053
next = Building.maybe_add_license(filename=next)
20572054
return next
2058-
else:
2059-
output = check_call(cmd, stdout=PIPE).stdout
2060-
output = Building.maybe_add_license(code=output)
2061-
return output
2062-
2063-
@staticmethod
2064-
def acorn_optimizer(filename, passes, extra_info=None, return_output=False):
2065-
return Building.js_optimizer_no_asmjs(filename, passes, extra_info=extra_info, return_output=return_output, acorn=True)
2055+
output = check_call(cmd, stdout=PIPE).stdout
2056+
output = Building.maybe_add_license(code=output)
2057+
return output
20662058

20672059
# evals ctors. if binaryen_bin is provided, it is the dir of the binaryen tool for this, and we are in wasm mode
20682060
@staticmethod

0 commit comments

Comments
 (0)