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:
Akinori Musha 2025-11-13 19:13:10 +09:00
parent 4a1b88afb8
commit 25c871fddf
Notes: git 2025-11-13 13:42:55 +00:00
2 changed files with 0 additions and 22 deletions

8
set.c
View File

@ -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);

View File

@ -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