On 23/09/2014 14:09, schu...@apache.org wrote: > Author: schultz > Date: Tue Sep 23 13:09:42 2014 > New Revision: 1627000 > > URL: http://svn.apache.org/r1627000 > Log: > Micro optimization.
What is the performance benefit of this change? Mark > > Modified: > tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java > > Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java?rev=1627000&r1=1626999&r2=1627000&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java (original) > +++ tomcat/trunk/java/org/apache/tomcat/util/buf/HexUtils.java Tue Sep 23 > 13:09:42 2014 > @@ -75,10 +75,12 @@ public final class HexUtils { > if (null == bytes) { > return null; > } > + final char[] hex = HexUtils.hex; > + final int length = bytes.length; > > - StringBuilder sb = new StringBuilder(bytes.length << 1); > + StringBuilder sb = new StringBuilder(length << 1); > > - for(int i = 0; i < bytes.length; ++i) { > + for(int i = 0; i < length; ++i) { > sb.append(hex[(bytes[i] & 0xf0) >> 4]) > .append(hex[(bytes[i] & 0x0f)]) > ; > @@ -94,8 +96,9 @@ public final class HexUtils { > } > > char[] inputChars = input.toCharArray(); > - byte[] result = new byte[input.length() >> 1]; > - for (int i = 0; i < result.length; i++) { > + final int length = input.length() >> 1; > + byte[] result = new byte[length]; > + for (int i = 0; i < length; i++) { > result[i] = (byte) ((getDec(inputChars[2*i]) << 4) + > getDec(inputChars[2*i + 1])); > } > return result; > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org