-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
This would probably be an good entry-point for someone looking to get involved in hacking JRuby.
There are a heap of single-method KindOf classes that look like:
fixnum.kindOf = new RubyModule.KindOf() {
@Override
public boolean isKindOf(IRubyObject obj, RubyModule type) {
return obj instanceof RubyFixnum;
}
}
Most of these could be replaced with a single implementation that uses Class.isInstance()
e.g.
public static final class JavaClassKindOf extends RubyModule.KindOf {
private final Class klass;
public JavaClassKindOf(Class klass) {
this.klass = klass;
}
@Override
public boolean isKindOf(IRubyObject obj, RubyModule type) {
return klass.isInstance(obj);
}
}
This wrinkle would be to benchmark this to make sure hotspot is optimising it the same way - intrinsic isInstance() might only be in very recent hotspot.
Reactions are currently unavailable