Skip to content

Commit 3443e43

Browse files
committed
Remove st_functions_t
1 parent e02c7a7 commit 3443e43

5 files changed

Lines changed: 26 additions & 38 deletions

File tree

parser_st.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ stat_col(void)
618618
entries. The real number of entries which the table can hold is
619619
the nearest power of two for SIZE. */
620620
st_table *
621-
st_init_table_with_size(const struct st_hash_type *type, st_functions_t *functions, st_index_t size)
621+
st_init_table_with_size(const struct st_hash_type *type, st_index_t size)
622622
{
623623
st_table *tab;
624624
int n;
@@ -642,7 +642,6 @@ st_init_table_with_size(const struct st_hash_type *type, st_functions_t *functio
642642
return NULL;
643643
#endif
644644
tab = (st_table *) malloc(sizeof (st_table));
645-
tab->functions = functions;
646645
#ifndef RUBY
647646
if (tab == NULL)
648647
return NULL;
@@ -684,55 +683,55 @@ st_table_size(const struct st_table *tbl)
684683
/* Create and return table with TYPE which can hold a minimal number
685684
of entries (see comments for get_power2). */
686685
st_table *
687-
st_init_table(const struct st_hash_type *type, st_functions_t *functions)
686+
st_init_table(const struct st_hash_type *type)
688687
{
689-
return st_init_table_with_size(type, functions, 0);
688+
return st_init_table_with_size(type, 0);
690689
}
691690

692691
/* Create and return table which can hold a minimal number of
693692
numbers. */
694693
st_table *
695-
st_init_numtable(st_functions_t *functions)
694+
st_init_numtable(void)
696695
{
697-
return st_init_table(&type_numhash, functions);
696+
return st_init_table(&type_numhash);
698697
}
699698

700699
/* Create and return table which can hold SIZE numbers. */
701700
st_table *
702-
st_init_numtable_with_size(st_functions_t *functions, st_index_t size)
701+
st_init_numtable_with_size(st_index_t size)
703702
{
704-
return st_init_table_with_size(&type_numhash, functions, size);
703+
return st_init_table_with_size(&type_numhash, size);
705704
}
706705

707706
/* Create and return table which can hold a minimal number of
708707
strings. */
709708
st_table *
710-
st_init_strtable(st_functions_t *functions)
709+
st_init_strtable(void)
711710
{
712-
return st_init_table(&type_strhash, functions);
711+
return st_init_table(&type_strhash);
713712
}
714713

715714
/* Create and return table which can hold SIZE strings. */
716715
st_table *
717-
st_init_strtable_with_size(st_functions_t *functions, st_index_t size)
716+
st_init_strtable_with_size(st_index_t size)
718717
{
719-
return st_init_table_with_size(&type_strhash, functions, size);
718+
return st_init_table_with_size(&type_strhash, size);
720719
}
721720

722721
/* Create and return table which can hold a minimal number of strings
723722
whose character case is ignored. */
724723
st_table *
725-
st_init_strcasetable(st_functions_t *functions)
724+
st_init_strcasetable(void)
726725
{
727-
return st_init_table(&type_strcasehash, functions);
726+
return st_init_table(&type_strcasehash);
728727
}
729728

730729
/* Create and return table which can hold SIZE strings whose character
731730
case is ignored. */
732731
st_table *
733-
st_init_strcasetable_with_size(st_functions_t *functions, st_index_t size)
732+
st_init_strcasetable_with_size(st_index_t size)
734733
{
735-
return st_init_table_with_size(&type_strcasehash, functions, size);
734+
return st_init_table_with_size(&type_strcasehash, size);
736735
}
737736

738737
/* Make table TAB empty. */
@@ -837,7 +836,7 @@ rebuild_table(st_table *tab)
837836
/* This allocation could trigger GC and compaction. If tab is the
838837
* gen_iv_tbl, then tab could have changed in size due to objects being
839838
* freed and/or moved. Do not store attributes of tab before this line. */
840-
new_tab = st_init_table_with_size(tab->type, tab->functions,
839+
new_tab = st_init_table_with_size(tab->type,
841840
2 * tab->num_entries - 1);
842841
new_entries = new_tab->entries;
843842
}

parser_st.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ struct parser_st_hash_type {
6767
parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
6868
};
6969

70-
typedef struct st_functions {
71-
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
72-
} st_functions_t;
73-
7470
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
7571

7672
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
@@ -100,22 +96,21 @@ struct parser_st_table {
10096
parser_st_index_t entries_start, entries_bound;
10197
/* Array of size 2^entry_power. */
10298
parser_st_table_entry *entries;
103-
st_functions_t *functions;
10499
};
105100

106101
#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
107102

108103
enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
109104

110105
size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
111-
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *, st_functions_t *);
112-
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, st_functions_t *, parser_st_index_t);
113-
parser_st_table *rb_parser_st_init_numtable(st_functions_t *);
114-
parser_st_table *rb_parser_st_init_numtable_with_size(st_functions_t *, parser_st_index_t);
115-
parser_st_table *rb_parser_st_init_strtable(st_functions_t *);
116-
parser_st_table *rb_parser_st_init_strtable_with_size(st_functions_t *, parser_st_index_t);
117-
parser_st_table *rb_parser_st_init_strcasetable(st_functions_t *);
118-
parser_st_table *rb_parser_st_init_strcasetable_with_size(st_functions_t *, parser_st_index_t);
106+
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *);
107+
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, parser_st_index_t);
108+
parser_st_table *rb_parser_st_init_numtable(void);
109+
parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
110+
parser_st_table *rb_parser_st_init_strtable(void);
111+
parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
112+
parser_st_table *rb_parser_st_init_strcasetable(void);
113+
parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
119114
int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
120115
int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
121116
int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */

ruby_parser.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,6 @@ rb_parser_config_initialize(rb_parser_config_t *config)
576576
{
577577
config->counter = 0;
578578

579-
config->st_functions.nonempty_memcpy = nonempty_memcpy;
580-
581579
config->malloc = ruby_xmalloc;
582580
config->calloc = ruby_xcalloc;
583581
config->realloc = ruby_xrealloc;

rubyparser.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ typedef struct rb_parser_config_struct {
341341
*/
342342
int counter;
343343

344-
/* For parser_st */
345-
st_functions_t st_functions;
346-
347344
/* Memory */
348345
void *(*malloc)(size_t size);
349346
void *(*calloc)(size_t number, size_t size);

universal_parser.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#define ST_CHECK ST2_CHECK
4949
#define ST_REPLACE ST2_REPLACE
5050
#undef st_init_numtable
51-
#define st_init_numtable() rb_parser_st_init_numtable((&p->config->st_functions))
51+
#define st_init_numtable rb_parser_st_init_numtable
5252
#undef st_free_table
5353
#define st_free_table rb_parser_st_free_table
5454
#undef st_init_table_with_size
@@ -393,8 +393,7 @@ struct rb_imemo_tmpbuf_struct {
393393
#define rb_node_case_when_optimizable_literal p->config->node_case_when_optimizable_literal
394394

395395
#undef st_init_table_with_size
396-
#define st_init_table_with_size(type, size) \
397-
rb_parser_st_init_table_with_size(type, &p->config->st_functions, size)
396+
#define st_init_table_with_size rb_parser_st_init_table_with_size
398397

399398
#define rb_ast_new() \
400399
rb_ast_new(p->config)

0 commit comments

Comments
 (0)