commit | 49ed0a9dee454e045eb54290cbacbdac081130b4 | [log] [tgz] |
---|---|---|
author | Radu Cotescu <radu@apache.org> | Wed Oct 21 09:51:13 2015 +0000 |
committer | Radu Cotescu <radu@apache.org> | Wed Oct 21 09:51:13 2015 +0000 |
tree | 3d63597bfc381cc7db15892aa254a9c8c83ad63b | |
parent | a4f5ee320766ac9d9f6bf2802115f4eab7bde392 [diff] |
SLING-5175 - The current set up of the ImporterTopLevel in the RhinoJavaScriptEngine incurs performance penalties * configured the ImporterTopLevel for the rootScope provided by the RhinoJavaScriptEngineFactory git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1709781 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngine.java b/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngine.java index d1d83ca..158ff22 100644 --- a/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngine.java +++ b/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngine.java
@@ -248,7 +248,7 @@ } else { // create the request top scope, use the ImporterToplevel here // to support the importPackage and importClasses functions - scope = new ImporterTopLevel(rhinoContext); + scope = new ImporterTopLevel(); // Set the global scope to be our prototype scope.setPrototype(rootScope);
diff --git a/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java index 8938205..bf8c83b 100644 --- a/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java +++ b/src/main/java/org/apache/sling/scripting/javascript/internal/RhinoJavaScriptEngineFactory.java
@@ -169,8 +169,8 @@ final Context rhinoContext = Context.enter(); try { - - Scriptable tmpScope = rhinoContext.initStandardObjects(new ImporterTopLevel(), false); + rhinoContext.setOptimizationLevel(optimizationLevel); + Scriptable tmpScope = rhinoContext.initStandardObjects(new ImporterTopLevel(rhinoContext), false); // default classes addHostObjects(tmpScope, (Class<? extends ScriptableObject>[]) HOSTOBJECT_CLASSES);