File tree 1 file changed +7
-10
lines changed
src/java.base/share/classes/java/nio/charset
1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 38
38
import java .security .PrivilegedAction ;
39
39
import java .util .Arrays ;
40
40
import java .util .Collections ;
41
- import java .util .HashSet ;
42
41
import java .util .Iterator ;
43
42
import java .util .Locale ;
44
43
import java .util .Map ;
@@ -667,7 +666,7 @@ public static Charset defaultCharset() {
667
666
668
667
private final String name ; // tickles a bug in oldjavac
669
668
private final String [] aliases ; // tickles a bug in oldjavac
670
- private Set <String > aliasSet = null ;
669
+ private Set <String > aliasSet ;
671
670
672
671
/**
673
672
* Initializes a new charset with the given canonical name and alias
@@ -714,14 +713,12 @@ public final String name() {
714
713
* @return An immutable set of this charset's aliases
715
714
*/
716
715
public final Set <String > aliases () {
717
- if (aliasSet != null )
718
- return aliasSet ;
719
- int n = aliases .length ;
720
- HashSet <String > hs = HashSet .newHashSet (n );
721
- for (int i = 0 ; i < n ; i ++)
722
- hs .add (aliases [i ]);
723
- aliasSet = Collections .unmodifiableSet (hs );
724
- return aliasSet ;
716
+ Set <String > set = this .aliasSet ;
717
+ if (set == null ) {
718
+ set = Set .of (aliases );
719
+ this .aliasSet = set ;
720
+ }
721
+ return set ;
725
722
}
726
723
727
724
/**
You can’t perform that action at this time.
0 commit comments