зеркало из https://github.com/github/ruby.git
use rb_hash_new_with_size()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
548698397a
Коммит
4fb1438b9d
|
@ -7203,7 +7203,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *const anchor,
|
|||
case TS_CDHASH:
|
||||
{
|
||||
int i;
|
||||
VALUE map = rb_hash_new();
|
||||
VALUE map = rb_hash_new_with_size(RARRAY_LEN(op)/2);
|
||||
|
||||
rb_hash_tbl_raw(map)->type = &cdhash_type;
|
||||
op = rb_convert_type_with_id(op, T_ARRAY, "Array", idTo_ary);
|
||||
|
@ -8525,7 +8525,7 @@ static VALUE
|
|||
ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
|
||||
{
|
||||
const struct ibf_object_hash *hash = IBF_OBJBODY(struct ibf_object_hash, offset);
|
||||
VALUE obj = rb_hash_new();
|
||||
VALUE obj = rb_hash_new_with_size(hash->len);
|
||||
int i;
|
||||
|
||||
for (i=0; i<hash->len; i++) {
|
||||
|
|
2
gc.c
2
gc.c
|
@ -6735,7 +6735,7 @@ static const char *type_name(int type, VALUE obj);
|
|||
static void
|
||||
gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
|
||||
{
|
||||
VALUE result = rb_hash_new();
|
||||
VALUE result = rb_hash_new_with_size(T_MASK);
|
||||
int i;
|
||||
for (i=0; i<T_MASK; i++) {
|
||||
const char *type = type_name(i, 0);
|
||||
|
|
6
re.c
6
re.c
|
@ -820,9 +820,9 @@ reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end,
|
|||
static VALUE
|
||||
rb_reg_named_captures(VALUE re)
|
||||
{
|
||||
VALUE hash = rb_hash_new();
|
||||
rb_reg_check(re);
|
||||
onig_foreach_name(RREGEXP_PTR(re), reg_named_captures_iter, (void*)hash);
|
||||
regex_t *reg = (rb_reg_check(re), RREGEXP_PTR(re));
|
||||
VALUE hash = rb_hash_new_with_size(onig_number_of_names(reg));
|
||||
onig_foreach_name(reg, reg_named_captures_iter, (void*)hash);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче