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: 8698c78c7c30
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dd63f008ccfb
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 7, 2016

  1. Copy the full SHA
    def4d4e View commit details
  2. Copy the full SHA
    e210215 View commit details
  3. Copy the full SHA
    dd63f00 View commit details
Showing with 14 additions and 4 deletions.
  1. +1 −1 spec/truffle/specs/truffle/digest.rb
  2. +13 −3 truffle/src/main/java/org/jruby/truffle/core/rope/RopeOperations.java
2 changes: 1 addition & 1 deletion spec/truffle/specs/truffle/digest.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
import org.jruby.Ruby;
import org.jruby.RubyEncoding;
import org.jruby.util.ByteList;
import org.jruby.util.Memo;
import org.jruby.util.StringSupport;
import org.jruby.util.io.EncodingUtils;

@@ -229,6 +230,11 @@ public static void visitBytes(Rope rope, BytesVisitor visitor, int offset, int l
final int leftLength = concat.getLeft().byteLength();

if (offset < leftLength) {
/*
* The left branch might not be large enough to extract the full byte range we want. In that case,
* we'll extract what we can and extract the difference from the right side.
*/

final int leftUsed;

if (offset + length > leftLength) {
@@ -280,18 +286,22 @@ public static void visitBytes(Rope rope, BytesVisitor visitor, int offset, int l

@TruffleBoundary
public static byte[] extractRange(Rope rope, int offset, int length) {
final ByteList result = new ByteList(length);
final byte[] result = new byte[length];

final Memo<Integer> resultPosition = new Memo<>(0);

visitBytes(rope, new BytesVisitor() {

@Override
public void accept(byte[] bytes, int offset, int length) {
result.append(bytes, offset, length);
final int resultPositionValue = resultPosition.get();
System.arraycopy(bytes, offset, result, resultPositionValue, length);
resultPosition.set(resultPositionValue + length);
}

}, offset, length);

return result.getUnsafeBytes();
return result;
}

/**