mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 14:56:28 +00:00
Perf opts
This commit is contained in:
@@ -14,14 +14,14 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
public class BiomeExtrusionProvider implements BiomeProvider {
|
||||
private final BiomeProvider delegate;
|
||||
private final Set<Biome> biomes;
|
||||
private final List<Extrusion> extrusions;
|
||||
private final Extrusion[] extrusions;
|
||||
private final int resolution;
|
||||
|
||||
public BiomeExtrusionProvider(BiomeProvider delegate, List<Extrusion> extrusions, int resolution) {
|
||||
this.delegate = delegate;
|
||||
this.biomes = delegate.stream().collect(Collectors.toSet());
|
||||
extrusions.forEach(e -> biomes.addAll(e.getBiomes()));
|
||||
this.extrusions = extrusions;
|
||||
this.extrusions = extrusions.toArray(new Extrusion[0]);
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class BiomeExtrusionProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
public Biome extrude(Biome original, int x, int y, int z, long seed) {
|
||||
for(Extrusion extrusion : extrusions) {
|
||||
original = extrusion.extrude(original, x, y, z, seed);
|
||||
for(int i = 0; i < extrusions.length; i++) {
|
||||
original = extrusions[i].extrude(original, x, y, z, seed);
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Context {
|
||||
private static final AtomicInteger size = new AtomicInteger(0);
|
||||
private static final Map<Class<? extends Properties>, PropertyKey<?>> properties = new HashMap<>();
|
||||
private final Map<Class<? extends Properties>, Properties> map = new HashMap<>();
|
||||
private final AtomicReference<Properties[]> list = new AtomicReference<>(new Properties[size.get()]);
|
||||
private Properties[] list = new Properties[size.get()];
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Properties> PropertyKey<T> create(Class<T> clazz) {
|
||||
@@ -38,19 +38,19 @@ public class Context {
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T extends Properties> Context put(PropertyKey<T> key, T properties) {
|
||||
list.updateAndGet(p -> {
|
||||
if(p.length == size.get()) return p;
|
||||
public synchronized <T extends Properties> Context put(PropertyKey<T> key, T properties) {
|
||||
if(list.length != size.get()) {
|
||||
Properties[] p2 = new Properties[size.get()];
|
||||
System.arraycopy(p, 0, p2, 0, p.length);
|
||||
return p2;
|
||||
})[key.key] = properties;
|
||||
System.arraycopy(list, 0, p2, 0, list.length);
|
||||
list = p2;
|
||||
}
|
||||
list[key.key] = properties;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Properties> T get(PropertyKey<T> key) {
|
||||
return (T) list.get()[key.key];
|
||||
return (T) list[key.key];
|
||||
}
|
||||
|
||||
public <T extends Properties> boolean has(Class<T> test) {
|
||||
|
||||
Reference in New Issue
Block a user