Skip to content

Commit ce822e5

Browse files
committed
fixed broken assertion
1 parent 98c2d00 commit ce822e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/ByteFormattingUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private enum Unit {
4444
// We want to respect MAX_WIDTH and keep it concise,
4545
// so we prefer to show 0.99MiB than 1010.00KiB (length 10).
4646
public static String bytesToHuman(long bytes) {
47-
assert bytes >= 0;
47+
assert bytes >= 0 : bytes;
4848
if (bytes < 1_000) {
4949
return bytes + "B";
5050
} else if (bytes < 1_000 * Unit.KiB.value) {
@@ -61,8 +61,9 @@ public static String bytesToHumanGB(long bytes) {
6161
}
6262

6363
private static String toHuman(long value, Unit unit) {
64-
String string = "%.2f%s".formatted((double) value / unit.value, unit);
65-
assert string.length() <= MAX_WIDTH || value >= 1000L * Unit.GiB.value;
64+
long scaled = value / unit.value;
65+
String string = "%.2f%s".formatted((double) scaled, unit.toString());
66+
assert string.length() <= MAX_WIDTH || value >= 1000L * Unit.GiB.value : value;
6667
return string;
6768
}
6869
}

0 commit comments

Comments
 (0)