Skip to content

Commit

Permalink
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -13,16 +13,16 @@
import org.jcodings.Encoding;
import org.jruby.util.ByteList;

public class MutableRope extends LeafRope {
public class RopeBuffer extends LeafRope {

private final ByteList byteList;

protected MutableRope(byte[] bytes, Encoding encoding, CodeRange codeRange, boolean singleByteOptimizable, int characterLength) {
protected RopeBuffer(byte[] bytes, Encoding encoding, CodeRange codeRange, boolean singleByteOptimizable, int characterLength) {
super(bytes, encoding, codeRange, singleByteOptimizable, characterLength);
this.byteList = new ByteList(bytes, encoding, true);
}

public MutableRope(Rope original) {
public RopeBuffer(Rope original) {
this(original.getBytes(),
original.getEncoding(),
original.getCodeRange(),
Original file line number Diff line number Diff line change
@@ -243,7 +243,7 @@ public MakeConcatNode(RubyContext context, SourceSection sourceSection) {
public abstract Rope executeMake(Rope left, Rope right, Encoding encoding);

@Specialization(guards = "isMutableRope(left)")
public Rope concatMutableRope(MutableRope left, Rope right, Encoding encoding,
public Rope concatMutableRope(RopeBuffer left, Rope right, Encoding encoding,
@Cached("createBinaryProfile()") ConditionProfile differentEncodingProfile) {
try {
ExactMath.addExact(left.byteLength(), right.byteLength());
@@ -314,7 +314,7 @@ private int depth(Rope left, Rope right) {
}

protected static boolean isMutableRope(Rope rope) {
return rope instanceof MutableRope;
return rope instanceof RopeBuffer;
}
}

Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@
import org.jruby.truffle.core.kernel.KernelNodesFactory;
import org.jruby.truffle.core.numeric.FixnumLowerNodeGen;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.MutableRope;
import org.jruby.truffle.core.rope.RopeBuffer;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeConstants;
import org.jruby.truffle.core.rope.RopeNodes;
@@ -1138,8 +1138,8 @@ public DynamicObject forceEncodingEncoding(DynamicObject string, DynamicObject r
final Rope rope = rope(string);

if (differentEncodingProfile.profile(rope.getEncoding() != encoding)) {
if (mutableRopeProfile.profile(rope instanceof MutableRope)) {
((MutableRope) rope).getByteList().setEncoding(encoding);
if (mutableRopeProfile.profile(rope instanceof RopeBuffer)) {
((RopeBuffer) rope).getByteList().setEncoding(encoding);
} else {
final Rope newRope = withEncodingNode.executeWithEncoding(rope, encoding, CodeRange.CR_UNKNOWN);
StringOperations.setRope(string, newRope);
@@ -1815,9 +1815,9 @@ public int size(DynamicObject string,
@Cached("createBinaryProfile()") ConditionProfile mutableRopeProfile) {
final Rope rope = rope(string);

if (mutableRopeProfile.profile(rope instanceof MutableRope)) {
if (mutableRopeProfile.profile(rope instanceof RopeBuffer)) {
// TODO (nirvdrum 11-Mar-16): This response is only correct for CR_7BIT. Mutable ropes have not been updated for multi-byte characters.
return ((MutableRope) rope).getByteList().realSize();
return ((RopeBuffer) rope).getByteList().realSize();
} else {
return rope.characterLength();
}
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@
import org.jruby.truffle.core.binding.BindingNodes;
import org.jruby.truffle.core.hash.BucketsStrategy;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.MutableRope;
import org.jruby.truffle.core.rope.RopeBuffer;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
@@ -456,8 +456,8 @@ public ConvertToMutableRope(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(string)")
public DynamicObject convertToMutableRope(DynamicObject string) {
final MutableRope mutableRope = new MutableRope(StringOperations.rope(string));
StringOperations.setRope(string, mutableRope);
final RopeBuffer ropeBuffer = new RopeBuffer(StringOperations.rope(string));
StringOperations.setRope(string, ropeBuffer);

return string;
}

1 comment on commit b720338

@eregon
Copy link
Member

@eregon eregon commented on b720338 Apr 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sorry, something went wrong.

Please sign in to comment.