Skip to content

Commit 90ff370

Browse files
committed
update: optimize disk logger
1 parent 7e5ffa6 commit 90ff370

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/io/github/optijava/opt_carpet_addition/logger/disk/DiskHUDLogger.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
public class DiskHUDLogger extends AbstractHUDLogger {
2121

2222
public static final DiskHUDLogger INSTANCE;
23+
private static final long TO_GB = 1024*1024*1024;
2324

2425
static {
2526
try {
@@ -35,8 +36,6 @@ protected DiskHUDLogger(Field acceleratorField, String logName, String def, Stri
3536

3637
@Override
3738
public void updateHUD(MinecraftServer server) {
38-
long toGB = 1024*1024*1024;
39-
4039
if (LoggerRegister.__disk) {
4140
//#if MC >= 11900
4241
//$$ List<Text> list = new ArrayList<>();
@@ -47,18 +46,18 @@ public void updateHUD(MinecraftServer server) {
4746
//#if MC >= 11900
4847
//$$ for (File f : File.listRoots()) {
4948
//$$ if (f.getPath().equals("/")) {
50-
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB))));
49+
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / TO_GB, f.getTotalSpace() / TO_GB))));
5150
//$$ } else {
52-
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB))));
51+
//$$ list.add(Text.of(Messenger.c("g %s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / TO_GB, f.getTotalSpace() / TO_GB))));
5352
//$$ }
5453
//$$ }
5554
//$$ LoggerRegistry.getLogger("disk").log(() -> list.toArray(new Text[0]));
5655
//#else
5756
for (File f : File.listRoots()) {
5857
if (f.getPath().equals("/")) {
59-
list.add(new LiteralText("%s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB)));
58+
list.add(new LiteralText("%s %sGB/%sGB".formatted("RootFileSystem", (f.getTotalSpace() - f.getFreeSpace()) / TO_GB, f.getTotalSpace() / TO_GB)));
6059
} else {
61-
list.add(new LiteralText("%s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / toGB, f.getTotalSpace() / toGB)));
60+
list.add(new LiteralText("%s %sGB/%sGB".formatted(f.getPath(), (f.getTotalSpace() - f.getFreeSpace()) / TO_GB, f.getTotalSpace() / TO_GB)));
6261
}
6362
}
6463
LoggerRegistry.getLogger("disk").log(() -> list.toArray(new BaseText[0]));

0 commit comments

Comments
 (0)