1
1
/*
2
- * Copyright (c) 2010, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2010, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
25
25
26
26
package java .lang ;
27
27
28
+ import jdk .internal .util .ArraysSupport ;
29
+
28
30
import java .io .DataInputStream ;
29
31
import java .io .InputStream ;
30
32
import java .lang .ref .SoftReference ;
31
33
import java .util .Arrays ;
32
- import java .util .Locale ;
33
34
import java .util .zip .InflaterInputStream ;
34
35
import java .security .AccessController ;
35
36
import java .security .PrivilegedAction ;
@@ -59,7 +60,7 @@ public InputStream run() {
59
60
int bkNum = dis .readInt ();
60
61
int cpNum = dis .readInt ();
61
62
int cpEnd = dis .readInt ();
62
- byte ba [] = new byte [cpEnd ];
63
+ byte [] ba = new byte [cpEnd ];
63
64
lookup = new int [bkNum * 256 ];
64
65
bkIndices = new int [(Character .MAX_CODE_POINT + 1 ) >> 8 ];
65
66
strPool = new byte [total - cpEnd ];
@@ -76,9 +77,9 @@ public InputStream run() {
76
77
int bk = -1 ;
77
78
int prevBk = -1 ; // prev bkNo;
78
79
int idx = 0 ;
79
- int next = - 1 ;
80
- int hash = 0 ;
81
- int hsh = 0 ;
80
+ int next ;
81
+ int hash ;
82
+ int hsh ;
82
83
do {
83
84
int len = ba [cpOff ++] & 0xff ;
84
85
if (len == 0 ) {
@@ -111,12 +112,8 @@ public InputStream run() {
111
112
}
112
113
}
113
114
114
- private static final int hashN (byte [] a , int off , int len ) {
115
- int h = 1 ;
116
- while (len -- > 0 ) {
117
- h = 31 * h + a [off ++];
118
- }
119
- return h ;
115
+ private static int hashN (byte [] a , int off , int len ) {
116
+ return ArraysSupport .vectorizedHashCode (a , off , len , 1 , ArraysSupport .T_BYTE );
120
117
}
121
118
122
119
private int addCp (int idx , int hash , int next , int cp ) {
@@ -132,7 +129,7 @@ private int addCp(int idx, int hash, int next, int cp) {
132
129
133
130
public static CharacterName getInstance () {
134
131
SoftReference <CharacterName > ref = refCharName ;
135
- CharacterName cname = null ;
132
+ CharacterName cname ;
136
133
if (ref == null || (cname = ref .get ()) == null ) {
137
134
cname = new CharacterName ();
138
135
refCharName = new SoftReference <>(cname );
@@ -141,7 +138,7 @@ public static CharacterName getInstance() {
141
138
}
142
139
143
140
public String getName (int cp ) {
144
- int off = 0 ;
141
+ int off ;
145
142
int bk = bkIndices [cp >> 8 ];
146
143
if (bk == -1 || (off = lookup [(bk << 8 ) + (cp & 0xff )]) == 0 )
147
144
return null ;
@@ -157,7 +154,7 @@ public int getCodePoint(String name) {
157
154
while (idx != -1 ) {
158
155
if (getCpHash (idx ) == hsh ) {
159
156
int cp = getCp (idx );
160
- int off = - 1 ;
157
+ int off ;
161
158
int bk = bkIndices [cp >> 8 ];
162
159
if (bk != -1 && (off = lookup [(bk << 8 ) + (cp & 0xff )]) != 0 ) {
163
160
int len = off & 0xff ;
0 commit comments