-
Notifications
You must be signed in to change notification settings - Fork 3
Scripts
Craig Minihan edited this page Dec 7, 2016
·
3 revisions
SpiderMonkey scripts differs from Context::Evaluate
because they are compiled once and executed many times. Compilation offers the best performance from your JavaScript since only one pass of the script is required to produce optimized runnable output:
rs::jsapi::Script script(cx, "(function(){return 42;})();");
script.Compile();
rs::jsapi::Value result(cx);
script.Execute(result);
In the above example script.Execute()
can be invoked multiple times without the need to compile or evaluate JavaScript code.