mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
Revert "[Bug #21513] Raise on converting endless range to set"
This reverts commit d4020dd5faf28486123853e7f00c36139fc07793, which introduced performance regression for objects like ActiveRecord::Relation by calling the costly #size method on them.
This commit is contained in:
parent
4a1b88afb8
commit
25c871fddf
Notes:
git
2025-11-13 13:42:55 +00:00
8
set.c
8
set.c
@ -509,14 +509,6 @@ set_i_initialize(int argc, VALUE *argv, VALUE set)
|
||||
}
|
||||
}
|
||||
else {
|
||||
ID id_size = rb_intern("size");
|
||||
if (rb_obj_is_kind_of(other, rb_mEnumerable) && rb_respond_to(other, id_size)) {
|
||||
VALUE size = rb_funcall(other, id_size, 0);
|
||||
if (RB_TYPE_P(size, T_FLOAT) && RFLOAT_VALUE(size) == INFINITY) {
|
||||
rb_raise(rb_eArgError, "cannot initialize Set from an object with infinite size");
|
||||
}
|
||||
}
|
||||
|
||||
rb_block_call(other, enum_method_id(other), 0, 0,
|
||||
rb_block_given_p() ? set_initialize_with_block : set_initialize_without_block,
|
||||
set);
|
||||
|
||||
@ -81,20 +81,6 @@ class TC_Set < Test::Unit::TestCase
|
||||
|
||||
s = Set.new(ary) { |o| o * 2 }
|
||||
assert_equal([2,4,6], s.sort)
|
||||
|
||||
assert_raise(ArgumentError) {
|
||||
Set.new((1..))
|
||||
}
|
||||
assert_raise(ArgumentError) {
|
||||
Set.new((1..), &:succ)
|
||||
}
|
||||
assert_raise(ArgumentError) {
|
||||
Set.new(1.upto(Float::INFINITY))
|
||||
}
|
||||
|
||||
assert_raise(ArgumentError) {
|
||||
Set.new(Object.new)
|
||||
}
|
||||
end
|
||||
|
||||
def test_clone
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user