aboutsummaryrefslogtreecommitdiff
path: root/tools/js_optimizer.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-21 21:27:05 +0100
committerAlon Zakai <alonzakai@gmail.com>2012-11-21 21:27:05 +0100
commite385931c501dcca3767e16fc8531150493131e59 (patch)
tree9bae2c7e85d54fcebcbd4526062ec87fc5e0b0ca /tools/js_optimizer.py
parent9ec292c78afd5e5bbd25ac152e16dbcc33a0e905 (diff)
finish js optimizer caching and add tests
Diffstat (limited to 'tools/js_optimizer.py')
-rw-r--r--tools/js_optimizer.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py
index 18f10ebc..a63fc794 100644
--- a/tools/js_optimizer.py
+++ b/tools/js_optimizer.py
@@ -81,7 +81,7 @@ def run(filename, passes, js_engine, jcache):
return True
chunks = filter(load_from_cache, chunks)
if len(cached_outputs) > 0:
- if out and DEBUG: print >> sys.stderr, ' loading %d funcchunks from jcache' % len(cached_outputs)
+ if DEBUG: print >> sys.stderr, ' loading %d jsfuncchunks from jcache' % len(cached_outputs)
else:
cached_outputs = []
@@ -95,8 +95,10 @@ def run(filename, passes, js_engine, jcache):
f.close()
return temp_file
filenames = [write_chunk(chunks[i], i) for i in range(len(chunks))]
+ elif len(chunks) == 1:
+ filenames = [filename] # avoid copying a single file
else:
- filenames = [filename]
+ filenames = []
if len(filenames) > 0:
# XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok)
@@ -132,8 +134,8 @@ def run(filename, passes, js_engine, jcache):
chunk = chunks[i]
keys = [chunk]
shortkey = shared.JCache.get_shortkey(keys)
- shared.JCache.set(shortkey, keys, outputs[i])
- if out and DEBUG and len(chunks) > 0: print >> sys.stderr, ' saving %d funcchunks to jcache' % len(chunks)
+ shared.JCache.set(shortkey, keys, open(filenames[i]).read())
+ if DEBUG and len(chunks) > 0: print >> sys.stderr, ' saving %d jsfuncchunks to jcache' % len(chunks)
return filename