Skip to content

Commit b51ad8b

Browse files
committedFeb 1, 2018
Minor refactoring after last PR (I like early returns vs nesting) and unused
assignment.
1 parent ec40e44 commit b51ad8b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/RubyNumeric.java

+6-11
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
import org.jruby.anno.JRubyClass;
3838
import org.jruby.anno.JRubyMethod;
3939
import org.jruby.ast.util.ArgsUtil;
40-
import org.jruby.common.RubyWarnings;
4140
import org.jruby.exceptions.RaiseException;
42-
import org.jruby.internal.runtime.methods.DynamicMethod;
4341
import org.jruby.javasupport.JavaUtil;
4442
import org.jruby.runtime.Block;
4543
import org.jruby.runtime.CallSite;
@@ -50,7 +48,6 @@
5048
import org.jruby.runtime.ThreadContext;
5149
import org.jruby.runtime.Visibility;
5250
import org.jruby.runtime.builtin.IRubyObject;
53-
import org.jruby.runtime.callsite.CachingCallSite;
5451
import org.jruby.util.ByteList;
5552
import org.jruby.util.ConvertBytes;
5653
import org.jruby.util.ConvertDouble;
@@ -480,12 +477,11 @@ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boo
480477
}
481478

482479
private static RubyArray coerceResult(final Ruby runtime, final IRubyObject result, final boolean err) {
483-
if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2 ) {
484-
if (err || !result.isNil()) throw runtime.newTypeError("coerce must return [x, y]");
485-
return null;
486-
}
480+
if (result instanceof RubyArray && ((RubyArray) result).getLength() == 2) return (RubyArray) result;
487481

488-
return (RubyArray) result;
482+
if (err || !result.isNil()) throw runtime.newTypeError("coerce must return [x, y]");
483+
484+
return null;
489485
}
490486

491487
/** coerce_rescue
@@ -952,9 +948,8 @@ else if (num instanceof RubyBignum) {
952948
return ((RubyBignum) num).isNegative(context).isTrue();
953949
}
954950
}
955-
IRubyObject r = UNDEF;
956-
r = stepCompareWithZero(context, num);
957-
return !r.isTrue();
951+
952+
return !stepCompareWithZero(context, num).isTrue();
958953
}
959954

960955
private IRubyObject stepCompareWithZero(ThreadContext context, IRubyObject num) {

0 commit comments

Comments
 (0)
Please sign in to comment.