Skip to content

Commit

Permalink
Showing 3 changed files with 7 additions and 21 deletions.
16 changes: 1 addition & 15 deletions truffle/src/main/java/org/jruby/truffle/core/rope/LazyRope.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.core.rope;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import org.jcodings.Encoding;

public abstract class LazyRope extends Rope {
@@ -23,20 +22,7 @@ protected byte getByteSlow(int index) {
return getBytes()[index];
}

public byte[] getBytes() {
if (bytes == null) {
doFulfill();
}

return bytes;
}

@TruffleBoundary
private void doFulfill() {
bytes = fulfill();
}

protected abstract byte[] fulfill();
protected abstract byte[] fulfill();

@Override
public String toString() {
10 changes: 5 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/rope/Rope.java
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ public final int byteLength() {
return byteLength;
}

public boolean isEmpty() {
public final boolean isEmpty() {
return byteLength == 0;
}

@@ -54,15 +54,15 @@ public final byte[] getRawBytes() {
return bytes;
}

public byte[] getBytes() {
public final byte[] getBytes() {
if (bytes == null) {
bytes = RopeOperations.flattenBytes(this);
}

return bytes;
}

public byte[] getBytesCopy() {
public final byte[] getBytesCopy() {
return getBytes().clone();
}

@@ -83,7 +83,7 @@ public final int depth() {
}

@Override
public int hashCode() {
public final int hashCode() {
if (hashCode == 0) {
hashCode = RopeOperations.hashForRange(this, 1, 0, byteLength);
}
@@ -92,7 +92,7 @@ public int hashCode() {
}

@Override
public boolean equals(Object o) {
public final boolean equals(Object o) {
if (this == o) {
return true;
}
Original file line number Diff line number Diff line change
@@ -273,7 +273,7 @@ public static byte[] flattenBytes(Rope rope) {

// Force lazy ropes
if (current instanceof LazyRope) {
current.getBytes();
((LazyRope) current).fulfill();
}

if (current.getRawBytes() != null) {

0 comments on commit 42aeb1e

Please sign in to comment.