< prev index next >

src/java.base/share/classes/java/lang/StringCoding.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -426,11 +426,11 @@
     @HotSpotIntrinsicCandidate
     private static int implEncodeISOArray(byte[] sa, int sp,
                                           byte[] da, int dp, int len) {
         int i = 0;
         for (; i < len; i++) {
-            char c = StringUTF16.getChar(sa, sp++);
+            char c = StringUTF16.Trusted.getChar(sa, sp++);
             if (c > '\u00FF')
                 break;
             da[dp++] = (byte)c;
         }
         return i;

@@ -448,13 +448,13 @@
         while (sp < sl) {
             int ret = implEncodeISOArray(val, sp, dst, dp, len);
             sp = sp + ret;
             dp = dp + ret;
             if (ret != len) {
-                char c = StringUTF16.getChar(val, sp++);
+                char c = StringUTF16.Trusted.getChar(val, sp++);
                 if (Character.isHighSurrogate(c) && sp < sl &&
-                    Character.isLowSurrogate(StringUTF16.getChar(val, sp))) {
+                    Character.isLowSurrogate(StringUTF16.Trusted.getChar(val, sp))) {
                     sp++;
                 }
                 dst[dp++] = '?';
                 len = sl - sp;
             }

@@ -479,17 +479,17 @@
         }
         int len = val.length >> 1;
         byte[] dst = new byte[len];
         int dp = 0;
         for (int i = 0; i < len; i++) {
-            char c = StringUTF16.getChar(val, i);
+            char c = StringUTF16.Trusted.getChar(val, i);
             if (c < 0x80) {
                 dst[dp++] = (byte)c;
                 continue;
             }
             if (Character.isHighSurrogate(c) && i + 1 < len &&
-                Character.isLowSurrogate(StringUTF16.getChar(val, i + 1))) {
+                Character.isLowSurrogate(StringUTF16.Trusted.getChar(val, i + 1))) {
                 i++;
             }
             dst[dp++] = '?';
         }
         if (len == dp) {

@@ -515,27 +515,27 @@
         } else {
             int sp = 0;
             int sl = val.length >> 1;
             dst = new byte[sl * 3];
             char c;
-            while (sp < sl && (c = StringUTF16.getChar(val, sp)) < '\u0080') {
+            while (sp < sl && (c = StringUTF16.Trusted.getChar(val, sp)) < '\u0080') {
                 // ascii fast loop;
                 dst[dp++] = (byte)c;
                 sp++;
             }
             while (sp < sl) {
-                c = StringUTF16.getChar(val, sp++);
+                c = StringUTF16.Trusted.getChar(val, sp++);
                 if (c < 0x80) {
                     dst[dp++] = (byte)c;
                 } else if (c < 0x800) {
                     dst[dp++] = (byte)(0xc0 | (c >> 6));
                     dst[dp++] = (byte)(0x80 | (c & 0x3f));
                 } else if (Character.isSurrogate(c)) {
                     int uc = -1;
                     char c2;
                     if (Character.isHighSurrogate(c) && sp < sl &&
-                        Character.isLowSurrogate(c2 = StringUTF16.getChar(val, sp))) {
+                        Character.isLowSurrogate(c2 = StringUTF16.Trusted.getChar(val, sp))) {
                         uc = Character.toCodePoint(c, c2);
                     }
                     if (uc < 0) {
                         dst[dp++] = '?';
                     } else {
< prev index next >