Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: da80b0bc2aa6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1a812c626a4d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 14, 2016

  1. Copy the full SHA
    23654a1 View commit details
  2. [Truffle] Ensure ropes converted to buffers don't end up modifying by…

    …te arrays for any ropes associated with the original one.
    nirvdrum committed Apr 14, 2016
    Copy the full SHA
    1a812c6 View commit details
Showing with 20 additions and 3 deletions.
  1. +2 −2 truffle/src/main/java/org/jruby/truffle/core/rope/RopeBuffer.java
  2. +18 −1 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
Original file line number Diff line number Diff line change
@@ -19,11 +19,11 @@ public class RopeBuffer extends LeafRope {

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);
this.byteList = new ByteList(bytes, encoding, false);
}

public RopeBuffer(Rope original) {
this(original.getBytes(),
this(original.getBytesCopy(),
original.getEncoding(),
original.getCodeRange(),
original.isSingleByteOptimizable(),
Original file line number Diff line number Diff line change
@@ -1755,7 +1755,7 @@ public SetByteNode(RubyContext context, SourceSection sourceSection) {
ToIntNodeGen.create(getContext(), getSourceSection(), value));
}

@Specialization
@Specialization(guards = "!isRopeBuffer(string)")
public int setByte(DynamicObject string, int index, int value) {
final int normalizedIndex = StringNodesHelper.checkIndexForRef(string, index, this);

@@ -1770,6 +1770,23 @@ public int setByte(DynamicObject string, int index, int value) {

return value;
}

@Specialization(guards = "isRopeBuffer(string)")
public int setByteRopeBuffer(DynamicObject string, int index, int value) {
final int normalizedIndex = StringNodesHelper.checkIndexForRef(string, index, this);

final RopeBuffer rope = (RopeBuffer) rope(string);

rope.getByteList().set(normalizedIndex, value);

return value;
}

protected boolean isRopeBuffer(DynamicObject string) {
assert RubyGuards.isRubyString(string);

return rope(string) instanceof RopeBuffer;
}
}

@CoreMethod(names = {"size", "length"})