jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
changeset 41882 0549e50db4bf
parent 40116 9bde91c0d0ef
child 46873 7ac2f551b0d6
--- a/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Wed Nov 02 18:45:14 2016 +0300
+++ b/jdk/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Wed Nov 02 20:53:56 2016 +0300
@@ -253,20 +253,20 @@
     }
 
     private static String toSourceString(char c) {
-        StringBuilder sb = new StringBuilder();
-        sb.append("'");
+        StringBuilder sb = new StringBuilder(4);
+        sb.append('\'');
         if (c == '\'')
             sb.append("\\'");
         else
             sb.append(c);
-        sb.append("'");
-        return sb.toString();
+        return sb.append('\'')
+                .toString();
     }
 
     private static String toSourceString(long ell) {
-        return (Math.abs(ell) <= Integer.MAX_VALUE) ?
-            String.valueOf(ell) :
-            (String.valueOf(ell) + "L");
+        String str = String.valueOf(ell);
+        return (ell < Integer.MIN_VALUE || ell > Integer.MAX_VALUE)
+                ? (str + 'L') : str;
     }
 
     /**
@@ -278,10 +278,7 @@
         sb.append('"');
         // Escape embedded quote characters, if present, but don't do
         // anything more heroic.
-        if (s.indexOf('"') != -1) {
-            s = s.replace("\"", "\\\"");
-        }
-        sb.append(s);
+        sb.append(s.replace("\"", "\\\""));
         sb.append('"');
         return sb.toString();
     }