# HG changeset patch # User hannesw # Date 1361180178 -3600 # Node ID 12f06c992c3af13291bee551bc922160e1a313c0 # Parent f5fdf89e1583af5260c7079535702f259d021966 8008351: Avoid using String.replace(String, String) in codegen Reviewed-by: sundar, attila diff -r f5fdf89e1583 -r 12f06c992c3a nashorn/src/jdk/nashorn/internal/codegen/Condition.java --- a/nashorn/src/jdk/nashorn/internal/codegen/Condition.java Mon Feb 18 14:41:58 2013 +0530 +++ b/nashorn/src/jdk/nashorn/internal/codegen/Condition.java Mon Feb 18 10:36:18 2013 +0100 @@ -39,7 +39,6 @@ import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLE; import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPLT; import static jdk.internal.org.objectweb.asm.Opcodes.IF_ICMPNE; -import jdk.nashorn.internal.ir.RuntimeNode; /** * Condition enum used for all kinds of jumps, regardless of type @@ -52,15 +51,6 @@ GE, GT; - static Condition forRuntimeRequest(final RuntimeNode.Request request) { - try { - final String reqString = request.toString().replace("_STRICT", ""); - return Condition.valueOf(reqString); - } catch (final IllegalArgumentException e) { - return null; - } - } - static int toUnary(final Condition c) { switch (c) { case EQ: @@ -81,10 +71,6 @@ } } - static int toBinary(final Condition c) { - return toBinary(c, false); - } - static int toBinary(final Condition c, final boolean isObject) { switch (c) { case EQ: diff -r f5fdf89e1583 -r 12f06c992c3a nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java --- a/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java Mon Feb 18 14:41:58 2013 +0530 +++ b/nashorn/src/jdk/nashorn/internal/codegen/RuntimeCallSite.java Mon Feb 18 10:36:18 2013 +0100 @@ -279,7 +279,7 @@ // number and boolean are never strictly equal, e.g. 0 !== false mh = MH.dropArguments(MH.constant(boolean.class, request == Request.NE_STRICT), 0, type().parameterArray()); } else { - mh = METHODS.get(request.name().replace("_STRICT", "") + primitiveType.getSimpleName()); + mh = METHODS.get(request.nonStrictName() + primitiveType.getSimpleName()); // unbox objects for (int i = 0; i < type().parameterCount(); i++) { diff -r f5fdf89e1583 -r 12f06c992c3a nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java --- a/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java Mon Feb 18 14:41:58 2013 +0530 +++ b/nashorn/src/jdk/nashorn/internal/ir/RuntimeNode.java Mon Feb 18 10:36:18 2013 +0100 @@ -145,6 +145,22 @@ } /** + * Get the non-strict name for this request. + * + * @return the name without _STRICT suffix + */ + public String nonStrictName() { + switch(this) { + case NE_STRICT: + return NE.name(); + case EQ_STRICT: + return EQ.name(); + default: + return name(); + } + } + + /** * Is this an EQ or EQ_STRICT? * * @param request a request