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

Commits on Feb 8, 2016

  1. Copy the full SHA
    741a7ea View commit details
  2. Copy the full SHA
    12d8d28 View commit details
  3. Copy the full SHA
    4150da5 View commit details
Original file line number Diff line number Diff line change
@@ -51,7 +51,6 @@ public boolean isEmpty() {

public final ByteList getUnsafeByteList() {
if (unsafeByteList == null) {
CompilerDirectives.transferToInterpreter();
unsafeByteList = new ByteList(getBytes(), getEncoding(), false);
}

10 changes: 5 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
Original file line number Diff line number Diff line change
@@ -288,12 +288,12 @@ private boolean isSingleByteOptimizable(Rope left, Rope right, ConditionProfile
}

private int depth(Rope left, Rope right) {
final int x = left.depth();
final int y = right.depth();

int maxChildDepth = x - ((x - y) & ((x - y) >> (Integer.SIZE - 1)));
return max(left.depth(), right.depth()) + 1;
}

return maxChildDepth + 1;
private int max(int x, int y) {
// This approach is adapted from http://graphics.stanford.edu/~seander/bithacks.html?1=1#IntegerMinOrMax
return x - ((x - y) & ((x - y) >> (Integer.SIZE - 1)));
}

protected static boolean isShortLeafRope(Rope rope) {
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import java.nio.charset.Charset;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.concurrent.ConcurrentHashMap;

import static org.jruby.truffle.core.rope.CodeRange.*;

@@ -37,6 +38,8 @@ public class RopeOperations {
public static final LeafRope EMPTY_US_ASCII_ROPE = create(new byte [] {}, USASCIIEncoding.INSTANCE, CR_7BIT);
public static final LeafRope EMPTY_UTF8_ROPE = create(new byte[] {}, UTF8Encoding.INSTANCE, CR_7BIT);

private static final ConcurrentHashMap<Encoding, Charset> encodingToCharsetMap = new ConcurrentHashMap<>();

public static LeafRope create(byte[] bytes, Encoding encoding, CodeRange codeRange) {
int characterLength = -1;

@@ -89,7 +92,12 @@ public static String decodeRope(Ruby runtime, Rope value) {
return RubyEncoding.decodeUTF8(value.getBytes(), begin, length);
}

Charset charset = runtime.getEncodingService().charsetForEncoding(encoding);
Charset charset = encodingToCharsetMap.get(encoding);

if (charset == null) {
charset = runtime.getEncodingService().charsetForEncoding(encoding);
encodingToCharsetMap.put(encoding, charset);
}

if (charset == null) {
try {