Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

3 participants

@kamilbednarz

Please see the following ticket for all the details:
http://jira.codehaus.org/browse/JRUBY-6915

@headius headius merged commit e2c3728 into from
@nirvdrum
Collaborator

Mind converting the tabs to spaces for consistency?

@kamilbednarz

nirvdrum,

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 authored
    …r on objects of different types.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/org/jruby/RubyComparable.java
View
5 src/org/jruby/RubyComparable.java
@@ -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.