Skip to content

Commit

Permalink
Merge branch 'master' into bytelist_love
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Apr 24, 2018
2 parents 3488484 + dfa0e71 commit 5cc5f85
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions core/src/main/java/org/jruby/RubyObject.java
Expand Up @@ -488,35 +488,34 @@ public IRubyObject op_eqq(ThreadContext context, IRubyObject other) {
* Helper method for checking equality, first using Java identity
* equality, and then calling the "==" method.
*/
public static boolean equalInternal(final ThreadContext context, final IRubyObject a, final IRubyObject b){
if (a == b) {
return true;
} else if (a instanceof RubySymbol) {
return false;
} else if (a instanceof RubyFixnum && b instanceof RubyFixnum) {
return ((RubyFixnum)a).fastEqual((RubyFixnum) b);
} else if (a instanceof RubyFloat && b instanceof RubyFloat) {
return ((RubyFloat)a).fastEqual((RubyFloat)b);
} else {
return invokedynamic(context, a, OP_EQUAL, b).isTrue();
public static boolean equalInternal(final ThreadContext context, final IRubyObject a, final IRubyObject b) {
if (a == b) return true;
if (a instanceof RubySymbol) return false;

return fastNumEqualInternal(context, a, b);
}

private static boolean fastNumEqualInternal(final ThreadContext context, final IRubyObject a, final IRubyObject b) {
if (a instanceof RubyFixnum) {
if (b instanceof RubyFixnum) return ((RubyFixnum) a).fastEqual((RubyFixnum) b);
} else if (a instanceof RubyFloat) {
if (b instanceof RubyFloat) return ((RubyFloat) a).fastEqual((RubyFloat) b);
}
return invokedynamic(context, a, OP_EQUAL, b).isTrue();
}

/**
* Helper method for checking equality, first using Java identity
* equality, and then calling the "eql?" method.
*/
protected static boolean eqlInternal(final ThreadContext context, final IRubyObject a, final IRubyObject b){
if (a == b) {
return true;
} else if (a instanceof RubySymbol) {
return false;
} else if (a instanceof RubyNumeric) {
if (a == b) return true;
if (a instanceof RubySymbol) return false;
if (a instanceof RubyNumeric) {
if (a.getClass() != b.getClass()) return false;
return equalInternal(context, a, b);
} else {
return invokedynamic(context, a, EQL, b).isTrue();
return fastNumEqualInternal(context, a, b);
}
return invokedynamic(context, a, EQL, b).isTrue();
}

/**
Expand Down

0 comments on commit 5cc5f85

Please sign in to comment.