mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Add rb_ident_set_new internal function
This is designed to replace rb_ident_hash_new calls when such hashes are used purely with with true values. To implement this, add a set_alloc_with_size_and_type static function, and have set_alloc_with_size and rb_ident_set_new call it.
This commit is contained in:
1 parent
7a0361b3fb
commit
85220035ca
1 file changed
+15
-2
Notes:
git
2026-08-25 14:03:40 +00:00
@@ -395,17 +395,22 @@ set_insert_wb(VALUE set, VALUE key)
|
||||
}
|
||||
|
||||
static VALUE
|
||||
set_alloc_with_size(VALUE klass, st_index_t size)
|
||||
set_alloc_with_size_and_type(VALUE klass, st_index_t size, const struct st_hash_type *type)
|
||||
{
|
||||
VALUE set;
|
||||
struct set_object *sobj;
|
||||
|
||||
set = TypedData_Make_Struct(klass, struct set_object, &set_data_type, sobj);
|
||||
set_init_table_with_size(&sobj->table, &objhash, size);
|
||||
set_init_table_with_size(&sobj->table, type, size);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
set_alloc_with_size(VALUE klass, st_index_t size)
|
||||
{
|
||||
return set_alloc_with_size_and_type(klass, size, &objhash);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
set_s_alloc(VALUE klass)
|
||||
@@ -2264,6 +2269,14 @@ compat_loader(VALUE self, VALUE a)
|
||||
return set_i_from_hash(self, rb_ivar_get(a, id_i_hash));
|
||||
}
|
||||
|
||||
/* Internal C-API functions */
|
||||
|
||||
VALUE
|
||||
rb_ident_set_new(void)
|
||||
{
|
||||
return set_alloc_with_size_and_type(rb_cSet, 0, &identhash);
|
||||
}
|
||||
|
||||
/* C-API functions */
|
||||
|
||||
void
|
||||
|
||||
Reference in new issue
Block a user