4 ms·
JavaScript compilers (in the sense of Java->JavaScript, not V8/TraceMonkey) already do this. Surprisingly inlining can help quite a bit in JS; due to how JS is
by tumult 17y ago
JavaScript compilers (in the sense of Java->JavaScript, not V8/TraceMonkey) already do this. Surprisingly inlining can help quite a bit in JS; due to how JS is "specified", there is extremely little room for interpreters to perform optimizations. Inlining code can save browsers from having to do lots of lookups and dereferences to functions in tight loops.
Scheme2JS, ocamljs, haxe, and others all do inlining. The code size gets a little bit larger, but if you have actual performance problems in loops, it can be worth it. Minify-ing and zip usually make JS code sizes trivial anyway.
- charlesmarshall 17y agothe Google closure compiler also does inlining on the top settings (compilation_level = ADVANCED_OPTIMIZATIONS) http://code.google.com/closure/compiler/docs/api-ref.html http://code.google.com/closure/compiler/docs/api-ref.html