Add isDebugEnabled check to not evaluate toShortString

Slightly more performant if debug logging not enabled. Could also use a Supplier taking overload of the .debug method, but that incurs additional lambda object creation that would most likely neglect any performance gains from not evaluating the toShortString method.
This commit is contained in:
Mustafa 2026-04-22 12:57:32 +03:00 committed by GitHub
parent ea9c7469bc
commit 29fc4b3ac8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -87,7 +87,9 @@ public abstract class LevelChunkMixin extends ChunkAccess {
BlockEntity blockEntity = this.getBlockEntity(pos.immutable(), LevelChunk.EntityCreationType.IMMEDIATE);
String blockName = state.getBlock().toString();
if (blockEntity != null) {
ModernFix.LOGGER.debug("Created missing block entity for {} at {}", blockName, pos.toShortString());
if (ModernFix.LOGGER.isDebugEnabled()) {
ModernFix.LOGGER.debug("Created missing block entity for {} at {}", blockName, pos.toShortString());
}
} else {
ModernFix.LOGGER.error("Block entity is missing for {} at {}, but could not be created", blockName, pos.toShortString());
}