# HG changeset patch # User cushon # Date 1556585655 25200 # Node ID 96ad739cfc397c821fb608efb73dc5c9c42813bf # Parent df2b3565f343adced309bfe8399e4b6e71b4d651 8219202: Use Unsynchronized StringBuilder in sun.net.www.ParseUtil Reviewed-by: chegar Contributed-by: Alan Malloy diff -r df2b3565f343 -r 96ad739cfc39 src/java.base/share/classes/sun/net/www/ParseUtil.java --- a/src/java.base/share/classes/sun/net/www/ParseUtil.java Thu May 02 09:49:52 2019 -0400 +++ b/src/java.base/share/classes/sun/net/www/ParseUtil.java Mon Apr 29 17:54:15 2019 -0700 @@ -146,7 +146,7 @@ /** * Appends the URL escape sequence for the specified char to the - * specified StringBuffer. + * specified character array. */ private static int escape(char[] cc, char c, int index) { cc[index++] = '%'; @@ -336,7 +336,7 @@ String query, String fragment) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (scheme != null) { sb.append(scheme); sb.append(':'); @@ -348,7 +348,7 @@ return sb.toString(); } - private static void appendSchemeSpecificPart(StringBuffer sb, + private static void appendSchemeSpecificPart(StringBuilder sb, String opaquePart, String authority, String userInfo, @@ -389,7 +389,7 @@ } } - private static void appendAuthority(StringBuffer sb, + private static void appendAuthority(StringBuilder sb, String authority, String userInfo, String host, @@ -437,7 +437,7 @@ } } - private static void appendFragment(StringBuffer sb, String fragment) { + private static void appendFragment(StringBuilder sb, String fragment) { if (fragment != null) { sb.append('#'); sb.append(quote(fragment, L_URIC, H_URIC)); @@ -449,14 +449,14 @@ // private static String quote(String s, long lowMask, long highMask) { int n = s.length(); - StringBuffer sb = null; + StringBuilder sb = null; boolean allowNonASCII = ((lowMask & L_ESCAPED) != 0); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c < '\u0080') { if (!match(c, lowMask, highMask) && !isEscaped(s, i)) { if (sb == null) { - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(s, 0, i); } appendEscape(sb, (byte)c); @@ -468,7 +468,7 @@ && (Character.isSpaceChar(c) || Character.isISOControl(c))) { if (sb == null) { - sb = new StringBuffer(); + sb = new StringBuilder(); sb.append(s, 0, i); } appendEncoded(sb, c); @@ -493,7 +493,7 @@ && match(s.charAt(pos + 2), L_HEX, H_HEX); } - private static void appendEncoded(StringBuffer sb, char c) { + private static void appendEncoded(StringBuilder sb, char c) { ByteBuffer bb = null; try { bb = ThreadLocalCoders.encoderFor("UTF-8") @@ -515,7 +515,7 @@ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - private static void appendEscape(StringBuffer sb, byte b) { + private static void appendEscape(StringBuilder sb, byte b) { sb.append('%'); sb.append(hexDigits[(b >> 4) & 0x0f]); sb.append(hexDigits[(b >> 0) & 0x0f]);