diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-29 12:30:30 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-29 12:30:30 -0700 |
commit | 7be5a908230091693fc68514ccef7dfb6bb65896 (patch) | |
tree | a9ea0ad1e7c1edf03c791eb554f8d9460ee5879a | |
parent | 2db1ec46f5a259e03c7866374086f11af30ff7da (diff) |
bump js minifier name limit, and optimize to not create all the names on smaller inputs
-rw-r--r-- | tools/js_optimizer.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index d6f8921c..dcc9cd5f 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -29,13 +29,13 @@ class Minifier: during registerize perform minification of locals. ''' - def __init__(self, js, js_engine): + def __init__(self, js, js_engine, MAX_NAMES): self.js = js self.js_engine = js_engine + MAX_NAMES = min(MAX_NAMES, 120000) # Create list of valid short names - MAX_NAMES = 80000 INVALID_2 = set(['do', 'if', 'in']) INVALID_3 = set(['for', 'new', 'try', 'var', 'env', 'let']) @@ -56,7 +56,6 @@ class Minifier: if len(self.names) >= MAX_NAMES: break curr = a + b + c if curr not in INVALID_3: self.names.append(curr) - #print >> sys.stderr, self.names def minify_shell(self, shell, minify_whitespace, source_map=False): #print >> sys.stderr, "MINIFY SHELL 1111111111", shell, "\n222222222222222" @@ -187,7 +186,8 @@ EMSCRIPTEN_FUNCS(); ''' + js[end_funcs + len(end_funcs_marker):end_asm + len(end_asm_marker)] js = js[start_funcs + len(start_funcs_marker):end_funcs] - minifier = Minifier(js, js_engine) + # we assume there is a maximum of one new name per line + minifier = Minifier(js, js_engine, js.count('\n') + asm_shell.count('\n')) asm_shell_pre, asm_shell_post = minifier.minify_shell(asm_shell, 'minifyWhitespace' in passes, source_map).split('EMSCRIPTEN_FUNCS();'); asm_shell_post = asm_shell_post.replace('});', '})'); pre += asm_shell_pre + '\n' + start_funcs_marker |