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

Commits on Dec 23, 2015

  1. Copy the full SHA
    de3d44d View commit details
  2. Copy the full SHA
    c42214e View commit details
  3. Copy the full SHA
    bae0a5f View commit details
Showing with 22 additions and 33 deletions.
  1. +0 −3 core/src/main/java/org/jruby/RubyArgsFile.java
  2. +10 −27 core/src/main/java/org/jruby/RubyComparable.java
  3. +12 −3 core/src/main/java/org/jruby/RubyObject.java
3 changes: 0 additions & 3 deletions core/src/main/java/org/jruby/RubyArgsFile.java
Original file line number Diff line number Diff line change
@@ -521,9 +521,6 @@ public static IRubyObject close(ThreadContext context, IRubyObject recv) {
ArgsFileData data = ArgsFileData.getDataFrom(recv);

data.next_argv(context);
if (isClosed(context, data.currentFile)) {
throw context.runtime.newIOError(RubyIO.CLOSED_STREAM_MSG);
}

argf_close(context, data.currentFile);

37 changes: 10 additions & 27 deletions core/src/main/java/org/jruby/RubyComparable.java
Original file line number Diff line number Diff line change
@@ -146,36 +146,19 @@ private static IRubyObject callCmpMethod(final ThreadContext context, final IRub
if (recv == other) return runtime.getTrue();

final IRubyObject $ex = context.getErrorInfo();
try {
IRubyObject result = runtime.execRecursiveOuter(new Ruby.RecursiveFunction() {
@Override
public IRubyObject call(IRubyObject obj, boolean recur) {
if (recur) return runtime.getNil();
return invokedynamic(context, recv, OP_CMP, other);
}
}, recv);

// This is only to prevent throwing exceptions by cmperr - it has poor performance
if ( result.isNil() ) return returnValueOnError;

return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0);
}
catch (RaiseException e) {
if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
cmpFailed(context);
// clear error info resulting from failure to compare (JRUBY-3292)
context.setErrorInfo($ex); // restore previous $! error (if any)
return returnValueOnError;

IRubyObject result = runtime.execRecursiveOuter(new Ruby.RecursiveFunction() {
@Override
public IRubyObject call(IRubyObject obj, boolean recur) {
if (recur) return runtime.getNil();
return invokedynamic(context, recv, OP_CMP, other);
}
throw e;
}
}
}, recv);

private static void cmpFailed(ThreadContext context) {
RubyWarnings warnings = context.runtime.getWarnings();
// This is only to prevent throwing exceptions by cmperr - it has poor performance
if ( result.isNil() ) return returnValueOnError;

warnings.warn("Comparable#== will no more rescue exceptions of #<=> in the next release.");
warnings.warn("Return nil in #<=> if the comparison is inappropriate or avoid such comparison.");
return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0);
}

/** cmp_gt
15 changes: 12 additions & 3 deletions core/src/main/java/org/jruby/RubyObject.java
Original file line number Diff line number Diff line change
@@ -541,13 +541,22 @@ public static RubyString inspect(ThreadContext context, IRubyObject object) {
static IRubyObject dig(ThreadContext context, IRubyObject obj, IRubyObject[] args, int idx) {
if ( obj.isNil() ) return context.nil;
if ( obj instanceof RubyArray ) {
return ((RubyArray) obj).dig(context, args, idx);
// TODO: cache somewhere
if (obj.getMetaClass().searchMethod("dig").isBuiltin()) {
return ((RubyArray) obj).dig(context, args, idx);
}
}
if ( obj instanceof RubyHash ) {
return ((RubyHash) obj).dig(context, args, idx);
// TODO: cache somewhere
if (obj.getMetaClass().searchMethod("dig").isBuiltin()) {
return ((RubyHash) obj).dig(context, args, idx);
}
}
if ( obj instanceof RubyStruct ) {
return ((RubyStruct) obj).dig(context, args, idx);
// TODO: cache somewhere
if (obj.getMetaClass().searchMethod("dig").isBuiltin()) {
return ((RubyStruct) obj).dig(context, args, idx);
}
}
if ( obj.respondsTo("dig") ) {
final int len = args.length - idx;