Skip to content


Improve performance of the Equals operator in the RubyComparable class for objects of different types #330

merged 1 commit into from

3 participants


Please see the following ticket for all the details:

@headius headius merged commit e2c3728 into jruby:master

1 check passed

Details default The Travis build passed

Mind converting the tabs to spaces for consistency?



Thanks for your remark.
I created a pull request, that fixes the indentation: #337

BTW, I deleted my previous message - I misunderstood you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 2, 2012
  1. @kamilbednarz

    Added workaround to prevent throwing exceptions when using == operato…

    kamilbednarz committed
    …r on objects of different types.
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/org/jruby/
5 src/org/jruby/
@@ -116,6 +116,11 @@ private static IRubyObject callCmpMethod(ThreadContext context, IRubyObject recv
try {
IRubyObject result = invokedynamic(context, recv, OP_CMP, other);
+ // 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()) {
Something went wrong with that request. Please try again.