Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -3303,7 +3303,7 @@ static VALUE
rb_ary_to_h(VALUE ary)
{
long i;
VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary));
VALUE hash = rb_hash_new_capa(RARRAY_LEN(ary));
int block_given = rb_block_given_p();

for (i=0; i<RARRAY_LEN(ary); i++) {
Expand Down Expand Up @@ -5739,7 +5739,7 @@ static inline VALUE
ary_tmp_hash_new(VALUE ary)
{
long size = RARRAY_LEN(ary);
VALUE hash = rb_hash_new_with_size(size);
VALUE hash = rb_hash_new_capa(size);

RBASIC_CLEAR_CLASS(hash);
return hash;
Expand Down
8 changes: 4 additions & 4 deletions box.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ box_entry_initialize(rb_box_t *box)
box->loaded_features_realpaths = rb_hash_dup(master->loaded_features_realpaths);
box->loaded_features_realpath_map = rb_hash_dup(master->loaded_features_realpath_map);
box->loading_table = st_init_strtable();
box->ruby_dln_libmap = rb_hash_new_with_size(0);
box->gvar_tbl = rb_hash_new_with_size(0);
box->ruby_dln_libmap = rb_hash_new();
box->gvar_tbl = rb_hash_new();
box->classext_cow_classes = st_init_numtable();

box->is_user = true;
Expand Down Expand Up @@ -902,8 +902,8 @@ initialize_master_box(void)
master->loaded_features_realpath_map = rb_hash_new();
rb_obj_hide(master->loaded_features_realpath_map);

master->ruby_dln_libmap = rb_hash_new_with_size(0);
master->gvar_tbl = rb_hash_new_with_size(0);
master->ruby_dln_libmap = rb_hash_new();
master->gvar_tbl = rb_hash_new();
master->classext_cow_classes = NULL; // classext CoW never happen on the master box

vm->master_box = master;
Expand Down
2 changes: 1 addition & 1 deletion compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -14428,7 +14428,7 @@ static VALUE
ibf_load_object_hash(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset)
{
long len = (long)ibf_load_small_value(load, &offset);
VALUE obj = header->frozen ? rb_hash_alloc_fixed_size(rb_cHash, len) : rb_hash_new_with_size(len);
VALUE obj = header->frozen ? rb_hash_alloc_fixed_size(rb_cHash, len) : rb_hash_new_capa(len);
int i;

for (i = 0; i < len; i++) {
Expand Down
23 changes: 11 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4756,12 +4756,6 @@ AS_IF([test ! -f "$srcdir/revision.h"], [

AS_IF([test "x$HAVE_BASERUBY" = xyes], [
X_DEPENDENCIES_DIR=.deps
AC_MSG_NOTICE([generating build dependencies])
rm -rf "$ac_pwd/.deps"
AS_MKDIR_P([.deps])
RUBYOPT=- $BASERUBY "$srcdir/tool/mkdepend.rb" \
--root="$srcdir" --scope=core --output="$ac_pwd/.deps" ||
AC_MSG_ERROR([failed to generate build dependencies])
], [
X_DEPENDENCIES_DIR='$(srcdir)'
])
Expand Down Expand Up @@ -4794,14 +4788,18 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [
done
sed '/^MISSING/s/\$U\././g;/^VCS *=/s#@VCS@#'"$VCS"'#;/^VCSUP *=/s#@VCSUP@#'"$VCSUP"'#' Makefile
echo; test x"$EXEEXT" = x || echo 'miniruby: miniruby$(EXEEXT)'
AS_IF([test "x$X_DEPENDENCIES_DIR" = x.deps -a "x$HAVE_BASERUBY" = xyes], [
AC_MSG_NOTICE([generating build dependencies])
${MAKE-make} -f "$srcdir/depend" BASERUBY="$BASERUBY" \
srcdir="$srcdir" update-dependencies >&AS_MESSAGE_FD ||
AC_MSG_ERROR([failed to generate build dependencies])
dependency_dir="$ac_pwd/.deps"
], [
dependency_dir=.
])
AS_IF([test "$gnumake" != yes], [
# extract NMake-style include list
set = `sed -n 's/^!include *//p' ${srcdir}/common.mk`
AS_IF([test "x$X_DEPENDENCIES_DIR" = x.deps], [
dependency_dir="$ac_pwd/.deps"
], [
dependency_dir=.
])
echo common_mk_includes "@S|@*" # generate the macro assignment
shift
common_mk_includes="`echo \"@S|@*\" | sed \
Expand All @@ -4819,7 +4817,8 @@ AC_CONFIG_FILES(Makefile:template/Makefile.in, [
echo; echo '$(srcdir)/$(CONFIGURE):RUBY_M4_INCLUDED \
$(empty)'
} > $tmpmk && mv -f $tmpmk Makefile],
[EXEEXT='$EXEEXT' MAKE='${MAKE-make}' gnumake='$gnumake' GIT='$GIT' YJIT_SUPPORT='$YJIT_SUPPORT' X_DEPENDENCIES_DIR='$X_DEPENDENCIES_DIR'])
[EXEEXT='$EXEEXT' MAKE='${MAKE-make}' gnumake='$gnumake' GIT='$GIT' YJIT_SUPPORT='$YJIT_SUPPORT'
X_DEPENDENCIES_DIR='$X_DEPENDENCIES_DIR' BASERUBY='$BASERUBY' HAVE_BASERUBY='$HAVE_BASERUBY'])

AC_ARG_WITH([ruby-pc],
AS_HELP_STRING([--with-ruby-pc=FILENAME], [pc file basename]),
Expand Down
9 changes: 8 additions & 1 deletion depend
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mkdepend: scan prism/*.c => prism/templates/src/*.c.erb
# mkdepend: scan prism/*.c => prism/templates/ext/prism/*.c.erb
# mkdepend: scan **/*.h => prism/templates/include/**/*.h.erb
# mkdepend: scan prism/*.h => prism/templates/include/prism/*.h.erb
# mkdepend: scan prism/**/*.h => prism/templates/include/prism/**/*.h.erb
# mkdepend: scan enc/trans/*.c => enc/trans/*.trans
# mkdepend: scan THREAD_IMPL_H => thread_$(THREAD_MODEL).h
# mkdepend: scan THREAD_IMPL_SRC => thread_$(THREAD_MODEL).c
Expand Down Expand Up @@ -35,6 +36,12 @@
# mkdepend: depends vmtc.inc => {$(VPATH)}vmtc.inc
# mkdepend: undef parse.y => RIPPER

.deps/depend update-dependencies: $(srcdir)/depend \
$(srcdir)/tool/mkdepend.rb \
$(srcdir)/lib/mkmf/depend.rb
$(BASERUBY) "$(srcdir)/tool/mkdepend.rb" --root="$(srcdir)" \
$(nmake:yes=--nmake) --scope=core --output=.deps

# AUTOGENERATED DEPENDENCIES START
addr2line.$(OBJEXT): {$(VPATH)}addr2line.c
array.$(OBJEXT): {$(VPATH)}array.c
Expand Down
2 changes: 1 addition & 1 deletion enumerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4671,7 +4671,7 @@ InitVM_Enumerator(void)
rb_define_method(rb_cLazy, "with_index", lazy_with_index, -1);
rb_define_method(rb_cLazy, "tap_each", lazy_tap_each, 0);

lazy_use_super_method = rb_hash_new_with_size(18);
lazy_use_super_method = rb_hash_new_capa(18);
rb_hash_aset(lazy_use_super_method, sym("map"), sym("_enumerable_map"));
rb_hash_aset(lazy_use_super_method, sym("collect"), sym("_enumerable_collect"));
rb_hash_aset(lazy_use_super_method, sym("flat_map"), sym("_enumerable_flat_map"));
Expand Down
6 changes: 3 additions & 3 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -10042,7 +10042,7 @@ 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_with_size(T_MASK);
VALUE result = rb_hash_new_capa(T_MASK);
int i;
for (i=0; i<T_MASK; i++) {
const char *type = type_name(i, 0);
Expand Down Expand Up @@ -12457,7 +12457,7 @@ rb_gc_impl_after_fork(void *objspace_ptr, rb_pid_t pid)
}
}

VALUE rb_ident_hash_new_with_size(st_index_t size);
VALUE rb_ident_hash_new_capa(long size);

#if GC_DEBUG_STRESS_TO_CLASS
/*
Expand All @@ -12473,7 +12473,7 @@ rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
rb_objspace_t *objspace = rb_gc_get_objspace();

if (!stress_to_class) {
set_stress_to_class(rb_ident_hash_new_with_size(argc));
set_stress_to_class(rb_ident_hash_new_capa(argc));
}

for (int i = 0; i < argc; i++) {
Expand Down
18 changes: 6 additions & 12 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,12 +1545,6 @@ copy_compare_by_id(VALUE hash, VALUE basis)
return hash;
}

VALUE
rb_hash_new_with_size(st_index_t size)
{
return hash_alloc_capa(rb_cHash, 0, Qnil, size, false);
}

VALUE
rb_hash_new_capa(long capa)
{
Expand Down Expand Up @@ -2722,7 +2716,7 @@ rb_hash_slice(int argc, VALUE *argv, VALUE hash)
if (argc == 0 || RHASH_EMPTY_P(hash)) {
return copy_compare_by_id(rb_hash_new(), hash);
}
result = copy_compare_by_id(rb_hash_new_with_size(argc), hash);
result = copy_compare_by_id(rb_hash_new_capa(argc), hash);

for (i = 0; i < argc; i++) {
key = argv[i];
Expand Down Expand Up @@ -3813,7 +3807,7 @@ to_h_i(VALUE key, VALUE value, VALUE hash)
static VALUE
rb_hash_to_h_block(VALUE hash)
{
VALUE h = rb_hash_new_with_size(RHASH_SIZE(hash));
VALUE h = rb_hash_new_capa(RHASH_SIZE(hash));
rb_hash_foreach(hash, to_h_i, h);
return h;
}
Expand Down Expand Up @@ -4208,7 +4202,7 @@ rb_hash_invert_i(VALUE key, VALUE value, VALUE hash)
static VALUE
rb_hash_invert(VALUE hash)
{
VALUE h = rb_hash_new_with_size(RHASH_SIZE(hash));
VALUE h = rb_hash_new_capa(RHASH_SIZE(hash));

rb_hash_foreach(hash, rb_hash_invert_i, h);
return h;
Expand Down Expand Up @@ -4813,7 +4807,7 @@ rb_ident_hash_new(void)
}

VALUE
rb_ident_hash_new_with_size(st_index_t size)
rb_ident_hash_new_capa(long size)
{
VALUE hash = rb_hash_new();
hash_st_table_init(hash, &identhash, size);
Expand Down Expand Up @@ -5203,7 +5197,7 @@ rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
VALUE
rb_hash_new_with_bulk_insert(long argc, const VALUE *argv)
{
VALUE val = rb_hash_new_with_size(argc / 2);
VALUE val = rb_hash_new_capa(argc / 2);
rb_hash_bulk_insert(argc, argv, val);
return val;
}
Expand Down Expand Up @@ -6229,7 +6223,7 @@ env_slice(int argc, VALUE *argv, VALUE _)
if (argc == 0) {
return rb_hash_new();
}
result = rb_hash_new_with_size(argc);
result = rb_hash_new_capa(argc);

for (i = 0; i < argc; i++) {
key = argv[i];
Expand Down
3 changes: 1 addition & 2 deletions internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_fu
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
bool rb_hash_default_unredefined(VALUE hash);
VALUE rb_hash_alloc_fixed_size(VALUE klass, st_index_t size);
VALUE rb_ident_hash_new_with_size(st_index_t size);
VALUE rb_ident_hash_new_capa(long size);
void rb_hash_free(VALUE hash);
RUBY_EXTERN VALUE rb_cHash_empty_frozen;

Expand All @@ -110,7 +110,6 @@ VALUE rb_ident_hash_new(void);
int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
RUBY_SYMBOL_EXPORT_END

VALUE rb_hash_new_with_size(st_index_t size);
VALUE rb_hash_new_with_bulk_insert(long argc, const VALUE *argv);
VALUE rb_hash_resurrect(VALUE hash);
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
Expand Down
2 changes: 1 addition & 1 deletion iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ make_compile_option(rb_compile_option_t *option, VALUE opt)
static VALUE
make_compile_option_value(rb_compile_option_t *option)
{
VALUE opt = rb_hash_new_with_size(11);
VALUE opt = rb_hash_new_capa(11);
#define SET_COMPILE_OPTION(o, h, mem) \
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), RBOOL((o)->mem))
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
Expand Down
Loading