9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-22 08:19:19 +00:00

move small patches

This commit is contained in:
NONPLAYT
2025-01-12 15:37:32 +03:00
parent 52b3d4b5a1
commit 864c30b001
15 changed files with 157 additions and 541 deletions

View File

@@ -0,0 +1,20 @@
package space.bxteam.divinemc.util.c2me;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.BitSet;
import java.util.function.IntFunction;
public class ObjectCachingUtils {
private static final IntFunction<BitSet> bitSetConstructor = BitSet::new;
public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
private ObjectCachingUtils() {}
public static BitSet getCachedOrNewBitSet(int bits) {
final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
bitSet.clear();
return bitSet;
}
}