This commit is contained in:
Nobuyoshi Nakada 2023-06-16 22:14:50 +09:00
Родитель e02c7a7340
Коммит 3443e43b62
5 изменённых файлов: 26 добавлений и 38 удалений

Просмотреть файл

@ -618,7 +618,7 @@ stat_col(void)
entries. The real number of entries which the table can hold is
the nearest power of two for SIZE. */
st_table *
st_init_table_with_size(const struct st_hash_type *type, st_functions_t *functions, st_index_t size)
st_init_table_with_size(const struct st_hash_type *type, st_index_t size)
{
st_table *tab;
int n;
@ -642,7 +642,6 @@ st_init_table_with_size(const struct st_hash_type *type, st_functions_t *functio
return NULL;
#endif
tab = (st_table *) malloc(sizeof (st_table));
tab->functions = functions;
#ifndef RUBY
if (tab == NULL)
return NULL;
@ -684,55 +683,55 @@ st_table_size(const struct st_table *tbl)
/* Create and return table with TYPE which can hold a minimal number
of entries (see comments for get_power2). */
st_table *
st_init_table(const struct st_hash_type *type, st_functions_t *functions)
st_init_table(const struct st_hash_type *type)
{
return st_init_table_with_size(type, functions, 0);
return st_init_table_with_size(type, 0);
}
/* Create and return table which can hold a minimal number of
numbers. */
st_table *
st_init_numtable(st_functions_t *functions)
st_init_numtable(void)
{
return st_init_table(&type_numhash, functions);
return st_init_table(&type_numhash);
}
/* Create and return table which can hold SIZE numbers. */
st_table *
st_init_numtable_with_size(st_functions_t *functions, st_index_t size)
st_init_numtable_with_size(st_index_t size)
{
return st_init_table_with_size(&type_numhash, functions, size);
return st_init_table_with_size(&type_numhash, size);
}
/* Create and return table which can hold a minimal number of
strings. */
st_table *
st_init_strtable(st_functions_t *functions)
st_init_strtable(void)
{
return st_init_table(&type_strhash, functions);
return st_init_table(&type_strhash);
}
/* Create and return table which can hold SIZE strings. */
st_table *
st_init_strtable_with_size(st_functions_t *functions, st_index_t size)
st_init_strtable_with_size(st_index_t size)
{
return st_init_table_with_size(&type_strhash, functions, size);
return st_init_table_with_size(&type_strhash, size);
}
/* Create and return table which can hold a minimal number of strings
whose character case is ignored. */
st_table *
st_init_strcasetable(st_functions_t *functions)
st_init_strcasetable(void)
{
return st_init_table(&type_strcasehash, functions);
return st_init_table(&type_strcasehash);
}
/* Create and return table which can hold SIZE strings whose character
case is ignored. */
st_table *
st_init_strcasetable_with_size(st_functions_t *functions, st_index_t size)
st_init_strcasetable_with_size(st_index_t size)
{
return st_init_table_with_size(&type_strcasehash, functions, size);
return st_init_table_with_size(&type_strcasehash, size);
}
/* Make table TAB empty. */
@ -837,7 +836,7 @@ rebuild_table(st_table *tab)
/* This allocation could trigger GC and compaction. If tab is the
* gen_iv_tbl, then tab could have changed in size due to objects being
* freed and/or moved. Do not store attributes of tab before this line. */
new_tab = st_init_table_with_size(tab->type, tab->functions,
new_tab = st_init_table_with_size(tab->type,
2 * tab->num_entries - 1);
new_entries = new_tab->entries;
}

Просмотреть файл

@ -67,10 +67,6 @@ struct parser_st_hash_type {
parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
};
typedef struct st_functions {
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
} st_functions_t;
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
@ -100,7 +96,6 @@ struct parser_st_table {
parser_st_index_t entries_start, entries_bound;
/* Array of size 2^entry_power. */
parser_st_table_entry *entries;
st_functions_t *functions;
};
#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
@ -108,14 +103,14 @@ struct parser_st_table {
enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *, st_functions_t *);
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, st_functions_t *, parser_st_index_t);
parser_st_table *rb_parser_st_init_numtable(st_functions_t *);
parser_st_table *rb_parser_st_init_numtable_with_size(st_functions_t *, parser_st_index_t);
parser_st_table *rb_parser_st_init_strtable(st_functions_t *);
parser_st_table *rb_parser_st_init_strtable_with_size(st_functions_t *, parser_st_index_t);
parser_st_table *rb_parser_st_init_strcasetable(st_functions_t *);
parser_st_table *rb_parser_st_init_strcasetable_with_size(st_functions_t *, parser_st_index_t);
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *);
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, parser_st_index_t);
parser_st_table *rb_parser_st_init_numtable(void);
parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
parser_st_table *rb_parser_st_init_strtable(void);
parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
parser_st_table *rb_parser_st_init_strcasetable(void);
parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */

Просмотреть файл

@ -576,8 +576,6 @@ rb_parser_config_initialize(rb_parser_config_t *config)
{
config->counter = 0;
config->st_functions.nonempty_memcpy = nonempty_memcpy;
config->malloc = ruby_xmalloc;
config->calloc = ruby_xcalloc;
config->realloc = ruby_xrealloc;

Просмотреть файл

@ -341,9 +341,6 @@ typedef struct rb_parser_config_struct {
*/
int counter;
/* For parser_st */
st_functions_t st_functions;
/* Memory */
void *(*malloc)(size_t size);
void *(*calloc)(size_t number, size_t size);

Просмотреть файл

@ -48,7 +48,7 @@
#define ST_CHECK ST2_CHECK
#define ST_REPLACE ST2_REPLACE
#undef st_init_numtable
#define st_init_numtable() rb_parser_st_init_numtable((&p->config->st_functions))
#define st_init_numtable rb_parser_st_init_numtable
#undef st_free_table
#define st_free_table rb_parser_st_free_table
#undef st_init_table_with_size
@ -393,8 +393,7 @@ struct rb_imemo_tmpbuf_struct {
#define rb_node_case_when_optimizable_literal p->config->node_case_when_optimizable_literal
#undef st_init_table_with_size
#define st_init_table_with_size(type, size) \
rb_parser_st_init_table_with_size(type, &p->config->st_functions, size)
#define st_init_table_with_size rb_parser_st_init_table_with_size
#define rb_ast_new() \
rb_ast_new(p->config)