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

Commits on Dec 24, 2015

  1. [Truffle] Replaced Arrays.asList with Collections.singletonList.

    This is a small performance optimization that avoids creating a backing array if we only have a single element in the list.
    nirvdrum committed Dec 24, 2015
    Copy the full SHA
    c754a41 View commit details
  2. 2
    Copy the full SHA
    3e6f8f1 View commit details
  3. Copy the full SHA
    917e35b View commit details
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ public Object cast(Object nil) {

@Specialization(guards = {"!isNil(object)", "!isRubyBignum(object)", "!isRubyArray(object)"})
public Object cast(VirtualFrame frame, DynamicObject object) {
final Object result = toArrayNode.call(frame, object, "to_ary", null, new Object[]{});
final Object result = toArrayNode.call(frame, object, "to_ary", null);

if (result == DispatchNode.MISSING) {
return nil();
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ public DynamicObject castHash(DynamicObject hash) {

@Specialization(guards = {"!isNil(object)", "!isRubyBignum(object)", "!isRubyHash(object)"})
public Object cast(VirtualFrame frame, DynamicObject object) {
final Object result = toHashNode.call(frame, object, "to_hash", null, new Object[]{});
final Object result = toHashNode.call(frame, object, "to_hash", null);

if (result == DispatchNode.MISSING) {
return nil();
Original file line number Diff line number Diff line change
@@ -416,7 +416,12 @@ private DynamicObject concatNumeric(DynamicObject string, int c) {
return string;
}

private DynamicObject charRangeException(Number value) {
private DynamicObject charRangeException(int value) {
return getContext().getCoreLibrary().rangeError(
String.format("%d out of char range", value), this);
}

private DynamicObject charRangeException(long value) {
return getContext().getCoreLibrary().rangeError(
String.format("%d out of char range", value), this);
}
Original file line number Diff line number Diff line change
@@ -3153,7 +3153,7 @@ public Object selectObject(VirtualFrame frame, DynamicObject array, DynamicObjec

CompilerDirectives.transferToInterpreter();

if (! yieldIsTruthy(frame, block, new Object[]{value})) {
if (! yieldIsTruthy(frame, block, value)) {
selectedStore = arrayBuilder.appendValue(selectedStore, selectedSize, value);
selectedSize++;
}
@@ -3544,7 +3544,7 @@ public Object selectObject(VirtualFrame frame, DynamicObject array, DynamicObjec

final Object value = store[n];

if (yieldIsTruthy(frame, block, new Object[]{value})) {
if (yieldIsTruthy(frame, block, value)) {
selectedStore = arrayBuilder.appendValue(selectedStore, selectedSize, value);
selectedSize++;
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import org.jruby.truffle.translator.Translator;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

@@ -48,7 +49,7 @@ public RubyNode makeWriteNode(RubyNode rhs) {
rhs, frameDepth, readFrameSlotNode.getFrameSlot());
}

public static final Set<String> ALWAYS_DEFINED_GLOBALS = new HashSet<>(Arrays.asList("$~"));
public static final Set<String> ALWAYS_DEFINED_GLOBALS = new HashSet<>(Collections.singletonList("$~"));

@Override
public Object isDefined(VirtualFrame frame) {
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

@@ -94,7 +95,7 @@ public List<String> formatBacktrace(DynamicObject exception, Backtrace backtrace

return lines;
} catch (Exception e) {
return Arrays.asList(String.format("(exception while constructing backtrace: %s %s)", e.getMessage(), e.getStackTrace()[0].toString()));
return Collections.singletonList(String.format("(exception while constructing backtrace: %s %s)", e.getMessage(), e.getStackTrace()[0].toString()));
}
}

Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ public Object execute(VirtualFrame frame) {
}
}

callNode.call(frame, ProcNodes.packArguments(block, new Object[] { binding }));
callNode.call(frame, ProcNodes.packArguments(block, binding));

return null;
}
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import org.jruby.truffle.translator.TranslatorDriver.ParserContext;

import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class SimpleShell {
@@ -108,7 +109,7 @@ private void backtrace(Node currentNode) {
System.console().writer().printf("%3d", n);
}

System.console().writer().println(BacktraceFormatter.createDefaultFormatter(context).formatLine(Arrays.asList(activation), 0));
System.console().writer().println(BacktraceFormatter.createDefaultFormatter(context).formatLine(Collections.singletonList(activation), 0));
n++;
}
}
Original file line number Diff line number Diff line change
@@ -699,7 +699,7 @@ public RubyNode visitCaseNode(org.jruby.ast.CaseNode node) {
if (when.getExpressionNodes() instanceof org.jruby.ast.ListNode && !(when.getExpressionNodes() instanceof org.jruby.ast.ArrayNode)) {
expressions = when.getExpressionNodes().childNodes();
} else {
expressions = Arrays.asList(when.getExpressionNodes());
expressions = Collections.singletonList(when.getExpressionNodes());
}

final List<RubyNode> comparisons = new ArrayList<>();
@@ -756,7 +756,7 @@ public RubyNode visitCaseNode(org.jruby.ast.CaseNode node) {
if (when.getExpressionNodes() instanceof org.jruby.ast.ListNode) {
expressions = when.getExpressionNodes().childNodes();
} else {
expressions = Arrays.asList(when.getExpressionNodes());
expressions = Collections.singletonList(when.getExpressionNodes());
}

final List<RubyNode> tests = new ArrayList<>();
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@

public abstract class Translator extends org.jruby.ast.visitor.AbstractNodeVisitor<RubyNode> {

public static final Set<String> ALWAYS_DEFINED_GLOBALS = new HashSet<>(Arrays.asList("$~"));
public static final Set<String> ALWAYS_DEFINED_GLOBALS = new HashSet<>(Collections.singletonList("$~"));
public static final Set<String> FRAME_LOCAL_GLOBAL_VARIABLES = new HashSet<>(Arrays.asList("$_", "$+", "$&", "$`", "$'"));

protected final Node currentNode;