Skip to content

Commit

Permalink
Showing 4 changed files with 0 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -40,19 +40,6 @@ public int get(int index) {
return right.get(index - left.byteLength());
}

@Override
@TruffleBoundary
public byte[] calculateBytes() {
final byte[] leftBytes = left.getBytes();
final byte[] rightBytes = right.getBytes();

final byte[] bytes = new byte[leftBytes.length + rightBytes.length];
System.arraycopy(leftBytes, 0, bytes, 0, leftBytes.length);
System.arraycopy(rightBytes, 0, bytes, leftBytes.length, rightBytes.length);

return bytes;
}

@Override
@TruffleBoundary
public byte[] extractRange(int offset, int length) {
@@ -99,28 +86,4 @@ public String toString() {
return left.toString() + right.toString();
}

@Override
protected void fillBytes(byte[] buffer, int bufferPosition, int offset, int byteLength) {
if (getRawBytes() != null) {
System.arraycopy(getRawBytes(), offset, buffer, bufferPosition, byteLength);
} else {
final int leftLength = left.byteLength();

if (offset < leftLength) {
// The left branch might not be large enough to extract the full hash code we want. In that case,
// we'll extract what we can and extract the difference from the right side.
if (offset + byteLength > leftLength) {
final int coveredByLeft = leftLength - offset;

left.fillBytes(buffer, bufferPosition, offset, coveredByLeft);
right.fillBytes(buffer, bufferPosition + coveredByLeft, 0, byteLength - coveredByLeft);

} else {
left.fillBytes(buffer, bufferPosition, offset, byteLength);
}
} else {
right.fillBytes(buffer, bufferPosition, offset - leftLength, byteLength);
}
}
}
}
11 changes: 0 additions & 11 deletions truffle/src/main/java/org/jruby/truffle/runtime/rope/LeafRope.java
Original file line number Diff line number Diff line change
@@ -24,11 +24,6 @@ public int get(int index) {
return getRawBytes()[index];
}

@Override
public byte[] calculateBytes() {
throw new UnsupportedOperationException("LeafRope's bytes are always known. There is no need to calculate them.");
}

@Override
public byte[] extractRange(int offset, int length) {
assert offset + length <= byteLength();
@@ -47,10 +42,4 @@ public String toString() {
return RopeOperations.decodeUTF8(this);
}

@Override
protected void fillBytes(byte[] buffer, int bufferPosition, int offset, int byteLength) {
assert offset + byteLength <= byteLength();

System.arraycopy(getRawBytes(), offset, buffer, bufferPosition, byteLength);
}
}
Original file line number Diff line number Diff line change
@@ -75,8 +75,6 @@ public byte[] getBytesCopy() {

public abstract byte[] extractRange(int offset, int length);

public abstract byte[] calculateBytes();

public final Encoding getEncoding() {
return encoding;
}
@@ -138,6 +136,4 @@ public boolean equals(Object o) {
return false;
}

protected abstract void fillBytes(byte[] buffer, int bufferPosition, int offset, int byteLength);

}
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@

package org.jruby.truffle.runtime.rope;

import org.jruby.RubyEncoding;

public class SubstringRope extends Rope {

private final Rope child;
@@ -29,11 +27,6 @@ public int get(int index) {
return child.get(index + offset);
}

@Override
public byte[] calculateBytes() {
return child.extractRange(offset, byteLength());
}

@Override
public byte[] extractRange(int offset, int length) {
assert length <= this.byteLength();
@@ -55,12 +48,4 @@ public String toString() {
return child.toString().substring(offset, offset + byteLength());
}

@Override
protected void fillBytes(byte[] buffer, int bufferPosition, int offset, int byteLength) {
if (getRawBytes() != null) {
System.arraycopy(getRawBytes(), offset, buffer, bufferPosition, byteLength);
} else {
child.fillBytes(buffer, bufferPosition, offset + this.offset, byteLength);
}
}
}

0 comments on commit 3d54c55

Please sign in to comment.