8229283: StringLatin1 should consistently use CharacterDataLatin1.instance when applicable
authorredestad
Fri, 09 Aug 2019 13:58:48 +0200
changeset 57701 90688c5ff482
parent 57700 def8e77a3ad1
child 57703 a64caa5269cf
8229283: StringLatin1 should consistently use CharacterDataLatin1.instance when applicable Reviewed-by: jlaskey
src/java.base/share/classes/java/lang/StringLatin1.java
--- a/src/java.base/share/classes/java/lang/StringLatin1.java	Fri Aug 09 13:07:18 2019 +0200
+++ b/src/java.base/share/classes/java/lang/StringLatin1.java	Fri Aug 09 13:58:48 2019 +0200
@@ -177,7 +177,7 @@
             char c1 = getChar(value, k);
             char c2 = StringUTF16.getChar(other, k);
             if (c1 != c2) {
-                c1 = Character.toUpperCase(c1);
+                c1 = (char) CharacterDataLatin1.instance.toUpperCase(c1);
                 c2 = Character.toUpperCase(c2);
                 if (c1 != c2) {
                     c1 = Character.toLowerCase(c1);
@@ -391,8 +391,8 @@
             if (c1 == c2) {
                 continue;
             }
-            char u1 = Character.toUpperCase(c1);
-            char u2 = Character.toUpperCase(c2);
+            int u1 = CharacterDataLatin1.instance.toUpperCase(c1);
+            int u2 = CharacterDataLatin1.instance.toUpperCase(c2);
             if (u1 == u2) {
                 continue;
             }
@@ -413,7 +413,7 @@
             if (c1 == c2) {
                 continue;
             }
-            char u1 = Character.toUpperCase(c1);
+            char u1 = (char) CharacterDataLatin1.instance.toUpperCase(c1);
             char u2 = Character.toUpperCase(c2);
             if (u1 == u2) {
                 continue;
@@ -435,7 +435,7 @@
         // Now check if there are any characters that need to be changed, or are surrogate
         for (first = 0 ; first < len; first++) {
             int cp = value[first] & 0xff;
-            if (cp != Character.toLowerCase(cp)) {  // no need to check Character.ERROR
+            if (cp != CharacterDataLatin1.instance.toLowerCase(cp)) {  // no need to check Character.ERROR
                 break;
             }
         }
@@ -450,7 +450,7 @@
                                                        // lowerCase characters.
         for (int i = first; i < len; i++) {
             int cp = value[i] & 0xff;
-            cp = Character.toLowerCase(cp);
+            cp = CharacterDataLatin1.instance.toLowerCase(cp);
             if (!canEncode(cp)) {                      // not a latin1 character
                 return toLowerCaseEx(str, value, first, locale, false);
             }
@@ -474,7 +474,7 @@
             if (localeDependent) {
                 lowerChar = ConditionalSpecialCasing.toLowerCaseEx(str, i, locale);
             } else {
-                lowerChar = Character.toLowerCase(srcChar);
+                lowerChar = CharacterDataLatin1.instance.toLowerCase(srcChar);
             }
             if (Character.isBmpCodePoint(lowerChar)) {    // Character.ERROR is not a bmp
                 StringUTF16.putChar(result, resultOffset++, lowerChar);
@@ -509,7 +509,7 @@
         // Now check if there are any characters that need to be changed, or are surrogate
         for (first = 0 ; first < len; first++ ) {
             int cp = value[first] & 0xff;
-            if (cp != Character.toUpperCaseEx(cp)) {   // no need to check Character.ERROR
+            if (cp != CharacterDataLatin1.instance.toUpperCaseEx(cp)) {   // no need to check Character.ERROR
                 break;
             }
         }
@@ -525,7 +525,7 @@
                                                        // upperCase characters.
         for (int i = first; i < len; i++) {
             int cp = value[i] & 0xff;
-            cp = Character.toUpperCaseEx(cp);
+            cp = CharacterDataLatin1.instance.toUpperCaseEx(cp);
             if (!canEncode(cp)) {                      // not a latin1 character
                 return toUpperCaseEx(str, value, first, locale, false);
             }
@@ -549,7 +549,7 @@
             if (localeDependent) {
                 upperChar = ConditionalSpecialCasing.toUpperCaseEx(str, i, locale);
             } else {
-                upperChar = Character.toUpperCaseEx(srcChar);
+                upperChar = CharacterDataLatin1.instance.toUpperCaseEx(srcChar);
             }
             if (Character.isBmpCodePoint(upperChar)) {
                 StringUTF16.putChar(result, resultOffset++, upperChar);
@@ -559,7 +559,7 @@
                         upperCharArray =
                             ConditionalSpecialCasing.toUpperCaseCharArray(str, i, locale);
                     } else {
-                        upperCharArray = Character.toUpperCaseCharArray(srcChar);
+                        upperCharArray = CharacterDataLatin1.instance.toUpperCaseCharArray(srcChar);
                     }
                 } else {
                     upperCharArray = Character.toChars(upperChar);
@@ -597,7 +597,7 @@
         int left = 0;
         while (left < length) {
             char ch = getChar(value, left);
-            if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+            if (ch != ' ' && ch != '\t' && !CharacterDataLatin1.instance.isWhitespace(ch)) {
                 break;
             }
             left++;
@@ -610,7 +610,7 @@
         int right = length;
         while (0 < right) {
             char ch = getChar(value, right - 1);
-            if (ch != ' ' && ch != '\t' && !Character.isWhitespace(ch)) {
+            if (ch != ' ' && ch != '\t' && !CharacterDataLatin1.instance.isWhitespace(ch)) {
                 break;
             }
             right--;