Optimize Util#sequence
This commit is contained in:
parent
03877441bd
commit
aba187d46e
@ -0,0 +1,29 @@
|
|||||||
|
package io.izzel.arclight.common.mixin.optimization.general;
|
||||||
|
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Mixin(Util.class)
|
||||||
|
public class UtilMixin_Optimize {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author IzzelAliz
|
||||||
|
* @reason original method allocates tons of garbage
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<? extends V>> futures) {
|
||||||
|
return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||||
|
.thenApply(v -> {
|
||||||
|
var list = new ArrayList<V>(futures.size());
|
||||||
|
for (CompletableFuture<? extends V> future : futures) {
|
||||||
|
list.add(future.join());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@
|
|||||||
"ClassInheritanceMultiMapMixin",
|
"ClassInheritanceMultiMapMixin",
|
||||||
"EntityDataManagerMixin_Optimize",
|
"EntityDataManagerMixin_Optimize",
|
||||||
"MobMixin_Optimization",
|
"MobMixin_Optimization",
|
||||||
|
"UtilMixin_Optimize",
|
||||||
"VoxelShapesMixin",
|
"VoxelShapesMixin",
|
||||||
"activationrange.ActivationRangeMixin",
|
"activationrange.ActivationRangeMixin",
|
||||||
"activationrange.EntityMixin_ActivationRange",
|
"activationrange.EntityMixin_ActivationRange",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user