mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 03:29:06 +00:00
Only compute if absent/present if compute is not needed (locking opts)
This commit is contained in:
@@ -167,11 +167,7 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
for (String i : objects) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sizeCache.compute(i, (k, v) -> {
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
||||
BlockVector bv = sizeCache.computeIfAbsent(i, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(i));
|
||||
} catch (IOException ex) {
|
||||
@@ -207,11 +203,7 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
for (String j : entry.getValue()) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sizeCache.compute(j, (k, v) -> {
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
||||
BlockVector bv = sizeCache.computeIfAbsent(j, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(j));
|
||||
} catch (IOException ioException) {
|
||||
|
||||
@@ -275,7 +275,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
if (!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) {
|
||||
return;
|
||||
}
|
||||
boolean u = false;
|
||||
boolean u = false;
|
||||
if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData()))
|
||||
{
|
||||
u = true;
|
||||
|
||||
@@ -329,12 +329,6 @@ public class PlannedStructure {
|
||||
public IrisObject rotated(IrisJigsawPiece piece, IrisObjectRotation rotation) {
|
||||
String key = piece.getObject() + "-" + rotation.hashCode();
|
||||
|
||||
return objectRotationCache.compute(key, (k, v) -> {
|
||||
if (v == null) {
|
||||
return rotation.rotateCopy(data.getObjectLoader().load(piece.getObject()));
|
||||
}
|
||||
|
||||
return v;
|
||||
});
|
||||
return objectRotationCache.computeIfAbsent(key, (k) -> rotation.rotateCopy(data.getObjectLoader().load(piece.getObject())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
return;
|
||||
}
|
||||
|
||||
positions.compute(Cache.key(rx, rz), (k, v) -> Objects.requireNonNullElseGet(v, (Supplier<KList<Integer>>) KList::new).qadd(yy));
|
||||
positions.computeIfAbsent(Cache.key(rx, rz), (k) -> new KList<>()).qadd(yy);
|
||||
|
||||
if (rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) {
|
||||
walls.put(new IrisPosition(rx, yy, rz + 1), c);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class IrisBiomeCustom {
|
||||
KMap<IrisBiomeCustomSpawnType, JSONArray> groups = new KMap<>();
|
||||
|
||||
for (IrisBiomeCustomSpawn i : getSpawns()) {
|
||||
JSONArray g = groups.compute(i.getGroup(), (k, v) -> v != null ? v : new JSONArray());
|
||||
JSONArray g = groups.computeIfAbsent(i.getGroup(), (k) -> new JSONArray());
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("type", "minecraft:" + i.getType().name().toLowerCase());
|
||||
o.put("weight", i.getWeight());
|
||||
|
||||
@@ -81,11 +81,7 @@ public class IrisObjectScale {
|
||||
return origin;
|
||||
}
|
||||
|
||||
return cache.compute(origin, (k, v) -> {
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
||||
return cache.computeIfAbsent(origin, (k) -> {
|
||||
KList<IrisObject> c = new KList<>();
|
||||
for (double i = minimumScale; i < maximumScale; i += (maximumScale - minimumScale) / (double) (Math.min(variations, 32))) {
|
||||
c.add(origin.scaled(i, getInterpolation()));
|
||||
|
||||
Reference in New Issue
Block a user