Skip to content

Commit cec0b0c

Browse files
author
Nicolas Laurent
committed
improve debugPrintConcatRopeBytes
1 parent 81b6d40 commit cec0b0c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/org/truffleruby/core/rope/RopeNodes.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,16 @@ protected Object debugPrintConcatRopeBytes(ConcatRope rope, int currentLevel, bo
808808
printPreamble(currentLevel);
809809

810810
final ConcatState state = rope.getState();
811+
812+
// Before the print, as `toString()` may cause the bytes to become populated.
813+
final boolean bytesAreNull = rope.getRawBytes() == null;
814+
811815
if (state.isBytes()) {
812816
System.err.println(StringUtils.format(
813817
"%s (%s; BN: %b; BL: %d; CL: %d; CR: %s; E: %s)",
814818
printString ? rope.toString() : "<skipped>",
815819
rope.getClass().getSimpleName(),
816-
false,
820+
bytesAreNull,
817821
rope.byteLength(),
818822
rope.characterLength(),
819823
rope.getCodeRange(),
@@ -823,8 +827,7 @@ protected Object debugPrintConcatRopeBytes(ConcatRope rope, int currentLevel, bo
823827
"%s (%s; BN: %b; BL: %d; CL: %d; CR: %s; E: %s)",
824828
printString ? rope.toString() : "<skipped>",
825829
rope.getClass().getSimpleName(),
826-
// Note: converting a rope to a java.lang.String may populate the byte[].
827-
true, // are bytes null?
830+
bytesAreNull,
828831
rope.byteLength(),
829832
rope.characterLength(),
830833
rope.getCodeRange(),

0 commit comments

Comments
 (0)