Permalink
Browse files

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

…r on objects of different types.
  • Loading branch information...
1 parent a04e24e commit 871159728318df610308cb0fa9d4675c0c8fa985 @kamilbednarz kamilbednarz committed Oct 2, 2012
Showing with 5 additions and 0 deletions.
  1. +5 −0 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()) {

0 comments on commit 8711597

Please sign in to comment.