-
Notifications
You must be signed in to change notification settings - Fork 21.8k
Allow Range#include?
on TWZ ranges
#31081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@rafaelfranca @matthewd wdyt? Previously I would've said just use |
Related, I've just submitted this to finally remove |
@pixeltrix Probably just me being paranoid, but is there a performance impact to this? It changes |
+1 this seems worth pursuing. Personally it seems to me that any object which doesn't respond to We don't even need to look at third party libraries to find them... Date and IPAddr come to mind. (Really I think that at least To this patch: Do we need I'm conscious that @al2o3cr we are adding an extra [ruby] method invocation, so it will certainly make it slower to call... but all the important work is still in C-land. If someone's in a truly hot path, they could fall back to using |
@al2o3cr we're already overriding @matthewd good call on |
@matthewd no need for static VALUE
range_eqq(VALUE range, VALUE val)
{
return rb_funcall(range, rb_intern("include?"), 1, val);
} |
In #11474 we prevented TWZ ranges being iterated over which matched Ruby's handling of Time ranges and as a consequence `include?` stopped working with both Time ranges and TWZ ranges. However in ruby/ruby@b061634 support was added for `include?` to use `cover?` for 'linear' objects. Since we have no way of making Ruby consider TWZ instances as 'linear' we have to override `Range#include?`. Fixes #30799.
47aea39
to
2b434d6
Compare
Changed |
In #11474 we prevented TWZ ranges being iterated over which matched Ruby's handling of Time ranges and as a consequence
include?
stopped working with both Time ranges and TWZ ranges. However in ruby/ruby@b061634 support was added forinclude?
to usecover?
for 'linear' objects. Since we have no way of making Ruby consider TWZ instances as 'linear' we have to overrideRange#include?
.