Skip to content

Commit

Permalink
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -58,6 +58,15 @@ public byte getByteSlow(int index) {
@Override
@TruffleBoundary
public byte[] extractRange(int offset, int length) {
assert length <= this.byteLength();

if (getRawBytes() != null) {
final byte[] ret = new byte[length];
System.arraycopy(getRawBytes(), offset, ret, 0, length);

return ret;
}

byte[] leftBytes;
byte[] rightBytes;
final int leftLength = left.byteLength();
@@ -79,7 +88,7 @@ public byte[] extractRange(int offset, int length) {
System.arraycopy(rightBytes, 0, ret, leftBytes.length, rightBytes.length);

return ret;
} else {
} else {
return leftBytes;
}
}
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
package org.jruby.truffle.core.rope;

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

public class SubstringRope extends Rope {
@@ -46,9 +47,17 @@ public byte getByteSlow(int index) {
}

@Override
@TruffleBoundary
public byte[] extractRange(int offset, int length) {
assert length <= this.byteLength();

if (getRawBytes() != null) {
final byte[] ret = new byte[length];
System.arraycopy(getRawBytes(), offset, ret, 0, length);

return ret;
}

return child.extractRange(this.offset + offset, length);
}

0 comments on commit 162361a

Please sign in to comment.