8302603: Use Set.of in java.nio.charset.Charset
Reviewed-by: stsypanov, alanb, naoto
This commit is contained in:
parent
10b4cc9eb4
commit
5489c821dc
@ -38,7 +38,6 @@ import java.security.AccessController;
|
|||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -667,7 +666,7 @@ public abstract class Charset
|
|||||||
|
|
||||||
private final String name; // tickles a bug in oldjavac
|
private final String name; // tickles a bug in oldjavac
|
||||||
private final String[] aliases; // tickles a bug in oldjavac
|
private final String[] aliases; // tickles a bug in oldjavac
|
||||||
private Set<String> aliasSet = null;
|
private Set<String> aliasSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new charset with the given canonical name and alias
|
* Initializes a new charset with the given canonical name and alias
|
||||||
@ -714,14 +713,12 @@ public abstract class Charset
|
|||||||
* @return An immutable set of this charset's aliases
|
* @return An immutable set of this charset's aliases
|
||||||
*/
|
*/
|
||||||
public final Set<String> aliases() {
|
public final Set<String> aliases() {
|
||||||
if (aliasSet != null)
|
Set<String> set = this.aliasSet;
|
||||||
return aliasSet;
|
if (set == null) {
|
||||||
int n = aliases.length;
|
set = Set.of(aliases);
|
||||||
HashSet<String> hs = HashSet.newHashSet(n);
|
this.aliasSet = set;
|
||||||
for (int i = 0; i < n; i++)
|
}
|
||||||
hs.add(aliases[i]);
|
return set;
|
||||||
aliasSet = Collections.unmodifiableSet(hs);
|
|
||||||
return aliasSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user