8267587: Update java.util to use enhanced switch

Reviewed-by: iris
This commit is contained in:
Tagir F. Valeev 2021-05-31 08:48:38 +00:00
parent 35916ed57f
commit ab5a7ff230
15 changed files with 556 additions and 776 deletions

View file

@ -655,23 +655,12 @@ public class Properties extends Hashtable<Object,Object> {
int value = 0;
for (int i = 0; i < 4; i++) {
aChar = in[off++];
switch (aChar) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
value = (value << 4) + aChar - '0';
break;
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
value = (value << 4) + 10 + aChar - 'a';
break;
case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F':
value = (value << 4) + 10 + aChar - 'A';
break;
default:
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.");
}
value = switch (aChar) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> (value << 4) + aChar - '0';
case 'a', 'b', 'c', 'd', 'e', 'f' -> (value << 4) + 10 + aChar - 'a';
case 'A', 'B', 'C', 'D', 'E', 'F' -> (value << 4) + 10 + aChar - 'A';
default -> throw new IllegalArgumentException("Malformed \\uxxxx encoding.");
};
}
out.append((char)value);
} else {