Skip to content

Commit 8de2a42

Browse files
author
Nicolas Laurent
committed
avoid having all ConcatRope fields null when getBytesSlow is called on its own
1 parent d9ae79b commit 8de2a42

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
public class ConcatRope extends ManagedRope {
2020

2121
/** Wrapper for the current state of the concat rope, including null children and a a byte array, or a null byte
22-
* array and the children. Accessing the state through {@link #getState()} guarantees the avoidance of race
23-
* conditions. */
22+
* array and the children. Accessing the state through {@link #getState()} avoids race conditions. */
2423
@ValueType
2524
public static class ConcatState {
2625
public final ManagedRope left, right;
@@ -92,10 +91,10 @@ private ConcatRope withEncoding(Encoding encoding, CodeRange codeRange, int char
9291

9392
@Override
9493
protected byte[] getBytesSlow() {
95-
final byte[] out = RopeOperations.flattenBytes(this);
96-
this.left = null;
97-
this.right = null;
98-
return out;
94+
bytes = RopeOperations.flattenBytes(this);
95+
left = null;
96+
right = null;
97+
return bytes;
9998
}
10099

101100
/** Access the state in a way that prevents race conditions.

0 commit comments

Comments
 (0)