aboutsummaryrefslogtreecommitdiff
path: root/tools/js_optimizer.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-01 18:26:58 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-11-01 18:26:58 -0700
commit3d48329892cd517b2e709ef94a00df8214169ddd (patch)
tree988d17b59d4fc2473a6d7a63df0f4117b711bcf4 /tools/js_optimizer.py
parent75af3c1ac8dba93b508b8b431bef9a35e6b054c3 (diff)
parent2c3d580bf9122ec4aef9ee8d462281d3fd810355 (diff)
Merge branch 'incoming' into f32
Conflicts: src/parseTools.js
Diffstat (limited to 'tools/js_optimizer.py')
-rw-r--r--tools/js_optimizer.py8
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