IJPL-594 update fastutil 8.5.11 -> 8.5.13 (part 2)

GitOrigin-RevId: 4f55be9e64dc4a484750762590056d478b746c97
This commit is contained in:
Vladimir Krivosheev
2024-02-06 16:21:10 +01:00
committed by intellij-monorepo-bot
parent c6b0575496
commit 82b321d57c
18 changed files with 268 additions and 197 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.containers;
import com.intellij.openapi.util.SystemInfoRt;
@@ -266,8 +266,8 @@ public final class CollectionFactory {
/**
* Return a {@link Map} implementation with slightly faster access for very big maps (>100K keys) and a bit smaller memory footprint
* than {@link HashMap}. Null keys and values are permitted. Use sparingly only when performance considerations are utterly important;
* in all other cases please prefer {@link HashMap}.
* than {@link java.util.HashMap}. Null keys and values are permitted. Use sparingly only when performance considerations are utterly important;
* in all other cases please prefer {@link java.util.HashMap}.
*/
@Contract(value = "-> new", pure = true)
public static <K, V> @NotNull Map<K, V> createSmallMemoryFootprintMap() {
@@ -381,8 +381,7 @@ public final class CollectionFactory {
return new Object2ObjectOpenCustomHashMap<>(adaptStrategy(strategy));
}
@NotNull
private static <K> Hash.Strategy<K> adaptStrategy(@NotNull HashingStrategy<? super K> strategy) {
private static @NotNull <K> Hash.Strategy<K> adaptStrategy(@NotNull HashingStrategy<? super K> strategy) {
return new FastUtilHashingStrategies.SerializableHashStrategy<K>() {
@Override
public int hashCode(@Nullable K o) {
@@ -399,12 +398,15 @@ public final class CollectionFactory {
public static <K,V> @NotNull Map<K,V> createCustomHashingStrategyMap(int expected, @NotNull HashingStrategy<? super K> strategy) {
return new Object2ObjectOpenCustomHashMap<>(expected, adaptStrategy(strategy));
}
public static <K> @NotNull Set<K> createCustomHashingStrategySet(@NotNull HashingStrategy<? super K> strategy) {
return new ObjectOpenCustomHashSet<>(adaptStrategy(strategy));
}
public static <K,V> @NotNull Map<K, V> createLinkedCustomHashingStrategyMap(@NotNull HashingStrategy<? super K> strategy) {
return new Object2ObjectLinkedOpenCustomHashMap<>(adaptStrategy(strategy));
}
public static <K> @NotNull Set<K> createLinkedCustomHashingStrategySet(@NotNull HashingStrategy<? super K> strategy) {
return new ObjectLinkedOpenCustomHashSet<>(adaptStrategy(strategy));
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.containers;
import com.intellij.openapi.util.io.FileUtilRt;
@@ -24,6 +24,18 @@ public final class FastUtilHashingStrategies {
private FastUtilHashingStrategies() {
}
public static final Hash.Strategy<String> FILE_PATH_HASH_STRATEGY = new Hash.Strategy<String>() {
@Override
public int hashCode(@Nullable String o) {
return FileUtilRt.pathHashCode(o);
}
@Override
public boolean equals(@Nullable String p1, @Nullable String p2) {
return FileUtilRt.pathsEqual(p1, p2);
}
};
public static final Hash.Strategy<File> FILE_HASH_STRATEGY = new SerializableHashStrategy<File>() {
@Override
public int hashCode(@Nullable File o) {

View File

@@ -1,9 +1,10 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.util.containers;
import com.intellij.openapi.util.io.FileUtilRt;
import it.unimi.dsi.fastutil.Hash;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenCustomHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import org.jetbrains.annotations.NotNull;
@@ -20,8 +21,9 @@ import java.util.Set;
* Creates map or set with canonicalized path hash strategy.
*/
public final class FileCollectionFactory {
private interface SerializableHashingStrategy<T> extends HashingStrategy<T>, Serializable {}
private static final HashingStrategy<File> FILE_HASH_STRATEGY = new SerializableHashingStrategy<File>() {
private interface SerializableHashingStrategy<T> extends Hash.Strategy<T>, Serializable {}
private static final SerializableHashingStrategy<File> FILE_HASH_STRATEGY = new SerializableHashingStrategy<File>() {
@Override
public int hashCode(@Nullable File o) {
return FileUtilRt.pathHashCode(o == null ? null : o.getPath());
@@ -32,17 +34,6 @@ public final class FileCollectionFactory {
return FileUtilRt.pathsEqual(a == null ? null : a.getPath(), b == null ? null : b.getPath());
}
};
public static final HashingStrategy<String> FILE_PATH_HASH_STRATEGY = new HashingStrategy<String>() {
@Override
public int hashCode(@Nullable String o) {
return FileUtilRt.pathHashCode(o);
}
@Override
public boolean equals(@Nullable String p1, @Nullable String p2) {
return FileUtilRt.pathsEqual(p1, p2);
}
};
/**
* Create linked map with canonicalized key hash strategy.
@@ -69,11 +60,11 @@ public final class FileCollectionFactory {
}
public static @NotNull <V> Map<File, V> createCanonicalFileMap() {
return CollectionFactory.createCustomHashingStrategyMap(FILE_HASH_STRATEGY);
return new Object2ObjectOpenCustomHashMap<>(FILE_HASH_STRATEGY);
}
public static @NotNull <V> Map<File, V> createCanonicalFileMap(int expected) {
return CollectionFactory.createCustomHashingStrategyMap(expected, FILE_HASH_STRATEGY);
return new Object2ObjectOpenCustomHashMap<>(expected, FILE_HASH_STRATEGY);
}
public static @NotNull <V> Map<File, V> createCanonicalFileMap(@NotNull Map<? extends File, ? extends V> map) {
@@ -83,7 +74,7 @@ public final class FileCollectionFactory {
}
public static @NotNull Set<File> createCanonicalFileSet() {
return CollectionFactory.createCustomHashingStrategySet(FILE_HASH_STRATEGY);
return new ObjectOpenCustomHashSet<>(FILE_HASH_STRATEGY);
}
public static @NotNull Set<File> createCanonicalFileSet(@NotNull Collection<? extends File> files) {
@@ -101,7 +92,7 @@ public final class FileCollectionFactory {
}
public static @NotNull Set<String> createCanonicalFilePathSet() {
return CollectionFactory.createCustomHashingStrategySet(FILE_PATH_HASH_STRATEGY);
return new ObjectOpenCustomHashSet<>(FastUtilHashingStrategies.FILE_PATH_HASH_STRATEGY);
}
public static @NotNull Set<File> createCanonicalFileLinkedSet() {