Skip to content

Commit

Permalink
massive performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Jun 19, 2024
1 parent d9349c5 commit 8f577b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public final class TrackingUtil {
public static final int WIDTH = 40;

public static void tickEntity(final Consumer<net.minecraft.world.entity.Entity> consumer, final net.minecraft.world.entity.Entity entity) {
Preconditions.checkArgument(entity instanceof Entity, String.format("Entity %s is not an instance of SpongeAPI's Entity!", entity));
Preconditions.checkArgument(entity instanceof Entity, () -> String.format("Entity %s is not an instance of SpongeAPI's Entity!", entity));
Objects.requireNonNull(entity, "Cannot capture on a null ticking entity!");
if (!((TrackableBridge) entity).bridge$shouldTick()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package org.spongepowered.common.util;

import java.util.function.Supplier;

public class Preconditions {

public static void checkState(final boolean expression, final String errorMessage) {
Expand All @@ -45,6 +47,12 @@ public static void checkArgument(final boolean expression, final String errorMes
}
}

public static void checkArgument(final boolean expression, final Supplier<String> errorMessage) {
if (!expression) {
throw new IllegalArgumentException(errorMessage.get());
}
}

public static void checkArgument(final boolean expression) {
if (!expression) {
// TODO we should ideally always have a message
Expand Down

0 comments on commit 8f577b7

Please sign in to comment.