From 1ef63471aac1189f7740d880c5577857106a7fd3 Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 15 Mar 2007 17:12:32 +0000 Subject: [PATCH] * Optimize WrapMaker methods a little bit. --- src/helma/scripting/rhino/RhinoCore.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/helma/scripting/rhino/RhinoCore.java b/src/helma/scripting/rhino/RhinoCore.java index f7b4dbe3..da185ccd 100644 --- a/src/helma/scripting/rhino/RhinoCore.java +++ b/src/helma/scripting/rhino/RhinoCore.java @@ -988,6 +988,12 @@ public final class RhinoCore implements ScopeProvider { class WrapMaker extends WrapFactory { public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) { + // taking a shortcut here on things normally defined by setJavaPrimitivesWrap() + if (obj == null || obj == Undefined.instance + || obj instanceof Scriptable || obj instanceof String + || obj instanceof Number || obj instanceof Boolean) { + return obj; + } // Wrap Nodes if (obj instanceof INode) { return getNodeWrapper((INode) obj); @@ -1017,6 +1023,9 @@ public final class RhinoCore implements ScopeProvider { } public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { + if (obj instanceof Scriptable) { + return (Scriptable) obj; + } if (obj instanceof INode) { return getNodeWrapper((INode) obj); }