# HG changeset patch # User Tom Rodriguez # Date 1412272494 25200 # Node ID fa821ca2611a8004748f90d9bd0d9ceb1903882f # Parent 3c39e028b9315fc7742f1d779cab2a9d3ff24bf7 Cache converted classfile name in debug mode diff -r 3c39e028b931 -r fa821ca2611a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Oct 02 08:43:58 2014 -0700 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Oct 02 10:54:54 2014 -0700 @@ -1210,9 +1210,13 @@ return createTimer(format, arg1, arg2); } - public static Object convertFormatArg(Object arg) { - if (arg instanceof Class) { - Class c = (Class) arg; + /** + * There are paths where construction of formatted class names are common and the code below is + * surprisingly expensive, so compute it once and cache it. + */ + private static final ClassValue formattedClassName = new ClassValue() { + @Override + protected String computeValue(Class c) { final String simpleName = c.getSimpleName(); Class enclosingClass = c.getEnclosingClass(); if (enclosingClass != null) { @@ -1226,6 +1230,12 @@ return simpleName; } } + }; + + public static Object convertFormatArg(Object arg) { + if (arg instanceof Class) { + return formattedClassName.get((Class) arg); + } return arg; }