Use standard (not Identity) HashMaps for OptionKeys and NodeMetadataKeys

This commit is contained in:
Luck 2019-12-13 14:02:31 +00:00
parent 37367fe91f
commit bd349ac4a3
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 8 additions and 5 deletions

View File

@ -32,10 +32,12 @@ import java.util.Objects;
final class SimpleOptionKey<T> implements OptionKey<T> {
private final String name;
private final Class<T> type;
private final int hashCode;
SimpleOptionKey(String name, Class<T> type) {
this.name = name.toLowerCase();
this.type = type;
this.hashCode = Objects.hash(this.name, this.type); // cache hashcode
}
@Override
@ -64,6 +66,6 @@ final class SimpleOptionKey<T> implements OptionKey<T> {
@Override
public int hashCode() {
return Objects.hash(this.name, this.type);
return this.hashCode;
}
}

View File

@ -39,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Objects;
@ -61,7 +62,7 @@ public abstract class AbstractNodeBuilder<N extends ScopedNode<N, B>, B extends
this.value = value;
this.expireAt = expireAt;
this.context = new ImmutableContextSetImpl.BuilderImpl().addAll(context);
this.metadata = new IdentityHashMap<>(metadata);
this.metadata = new HashMap<>(metadata);
}
@Override

View File

@ -38,7 +38,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.EnumSet;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@ -124,9 +124,9 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder {
if (this.options == null || this.copyOptions) {
if (this.options != null) {
this.options = new IdentityHashMap<>(this.options);
this.options = new HashMap<>(this.options);
} else {
this.options = new IdentityHashMap<>();
this.options = new HashMap<>();
}
this.copyOptions = false;
}