Skip to content

Commit

Permalink
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -761,7 +761,8 @@ public IRubyObject op_pow_19(ThreadContext context, IRubyObject other) {
if (other instanceof RubyNumeric) {
double d_other = ((RubyNumeric) other).getDoubleValue();
if (value < 0 && (d_other != Math.round(d_other))) {
return RubyComplex.newComplexRaw(context.runtime, this).callMethod(context, "**", other);
RubyComplex complex = RubyComplex.newComplexRaw(context.runtime, this);
return sites(context).op_exp_complex.call(context, complex, complex, other);
}
if (other instanceof RubyFixnum) {
return powerFixnum19(context, other);
@@ -774,8 +775,9 @@ private IRubyObject powerOther19(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
long a = value;
if (other instanceof RubyBignum) {
if (other.callMethod(context, "<", RubyFixnum.zero(runtime)).isTrue()) {
return RubyRational.newRationalRaw(runtime, this).callMethod(context, "**", other);
if (sites(context).op_lt_bignum.call(context, other, other, RubyFixnum.zero(runtime)).isTrue()) {
RubyRational rational = RubyRational.newRationalRaw(runtime, this);
return sites(context).op_exp_rational.call(context, rational, rational, other);
}
if (a == 0) return RubyFixnum.zero(runtime);
if (a == 1) return RubyFixnum.one(runtime);
@@ -797,7 +799,8 @@ private IRubyObject powerFixnum19(ThreadContext context, IRubyObject other) {
long a = value;
long b = ((RubyFixnum) other).value;
if (b < 0) {
return RubyRational.newRationalRaw(runtime, this).callMethod(context, "**", other);
RubyRational rational = RubyRational.newRationalRaw(runtime, this);
return sites(context).op_exp_rational.call(context, rational, rational, other);
}
if (b == 0) {
return RubyFixnum.one(runtime);
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/runtime/JavaSites.java
Original file line number Diff line number Diff line change
@@ -168,6 +168,9 @@ public static class FixnumSites {
public final CallSite op_le = new FunctionalCachingCallSite("<=");
public final CallSite op_gt = new FunctionalCachingCallSite(">");
public final CallSite op_lt = new FunctionalCachingCallSite("<");
public final CallSite op_exp_complex = new FunctionalCachingCallSite("**");
public final CallSite op_lt_bignum = new FunctionalCachingCallSite("<");
public final CallSite op_exp_rational = new FunctionalCachingCallSite("**");
}

public static class BignumSites {

0 comments on commit 11b3d79

Please sign in to comment.