Closed iccir closed 8 years ago
So currently, OJ runs one-off:
ojc.compile(options, cb(err, res))
But with this, we'd construct a compiler?
// Something like...
var cc = new ojc.compiler(options);
cc.compile(cb(err, res))
Or how is this to be understood?
Yep, that's exactly it. You would keep cc
around, and then call cc.compile
on it again in response to a file change.
Oh! Now that’s pretty cool. :) Looking forward to seeing that in action.
On branch and documented. Note that Compiler#parent
is now Compiler#uses
.
oj should provide a
Compiler
API in addition tocompile
. In addition to the constructor, this would have two methods:The
parent
method replaces the need for theinput-state
andoutput-state
options. Rather than serializing/deserializing, input state is read directly from the parent compiler.The first call to
compile
is effectively the same as thecompile()
API. Subsequent calls tocompile
should reuse pieces from previous compiles, including the typechecker, to allow for faster incremental builds.From my prototype in the 2.0 branch, running the type checker goes from ~5.2 seconds per save to ~1.5 seconds per save (assuming there isn't a global change, like a class rename). Non-typechecker passes are about the same speed.