mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-28 11:29:11 +00:00
Originally vanilla logic is to use stream, and Mojang switched it to Guava's Collections2 since 1.21.4. It is much faster than using stream or manually adding to a new ArrayList. Manually adding to a new ArrayList requires allocating a new object array. However, the Collections2 lazy handles filter condition on iteration, so much better.
25 lines
1.3 KiB
Diff
25 lines
1.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Thu, 7 Nov 2024 19:45:31 +0100
|
|
Subject: [PATCH] C2ME: Reduce Allocations
|
|
|
|
This patch is based on the following mixin:
|
|
"com/ishland/c2me/opts/allocs/mixin/object_pooling_caching/MixinOreFeature.java"
|
|
By: ishland <ishlandmc@yeah.net>
|
|
As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
diff --git a/net/minecraft/world/level/levelgen/feature/OreFeature.java b/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
|
index c7b46efd4f08067e2c9c5c8b0e8b71a94a79823d..d14609e932f2ce4e97d1e354b424cc3ec86bd25b 100644
|
|
--- a/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
|
+++ b/net/minecraft/world/level/levelgen/feature/OreFeature.java
|
|
@@ -69,7 +69,7 @@ public class OreFeature extends Feature<OreConfiguration> {
|
|
int height
|
|
) {
|
|
int i = 0;
|
|
- BitSet bitSet = new BitSet(width * height * width);
|
|
+ BitSet bitSet = org.dreeam.leaf.util.cache.CachedOrNewBitsGetter.getCachedOrNewBitSet(width * height * width); // Leaf - C2ME - Reduce Allocations
|
|
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
|
int i1 = config.size;
|
|
double[] doubles = new double[i1 * 4];
|