Skip to content

Commit

Permalink
Supress `warning: ‘rb_parser_str_hash’ defined but not used [-Wunused…
Browse files Browse the repository at this point in the history
…-function]`
  • Loading branch information
jinroq committed Feb 14, 2024
1 parent eea7ce5 commit a669207
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,31 @@ node_cdhash_cmp(VALUE val, VALUE lit)
}

static st_index_t rb_parser_str_hash(rb_parser_string_t *str);
#ifndef RIPPER
static st_index_t
djb2(const uint8_t *str, size_t len)
{
st_index_t hash = 5381;

for (size_t i = 0; i < len; i++) {
hash = ((hash << 5) + hash) + str[i];
}

return hash;
}

static st_index_t
parser_memhash(const void *ptr, long len)
{
return djb2(ptr, len);
}

static st_index_t
rb_parser_str_hash(rb_parser_string_t *str)
{
return parser_memhash((const void *)PARSER_STRING_PTR(str), PARSER_STRING_LEN(str));
}
#endif

static st_index_t
node_cdhash_hash(VALUE a)
Expand Down Expand Up @@ -2140,24 +2165,6 @@ get_nd_args(struct parser_params *p, NODE *node)
return 0;
}
}

static st_index_t
djb2(const uint8_t *str, size_t len)
{
st_index_t hash = 5381;

for (size_t i = 0; i < len; i++) {
hash = ((hash << 5) + hash) + str[i];
}

return hash;
}

static st_index_t
parser_memhash(const void *ptr, long len)
{
return djb2(ptr, len);
}
#endif

#define PARSER_STRING_PTR(str) (str->ptr)
Expand Down Expand Up @@ -2216,12 +2223,6 @@ rb_parser_string_free(rb_parser_t *p, rb_parser_string_t *str)
}

#ifndef RIPPER
static st_index_t
rb_parser_str_hash(rb_parser_string_t *str)
{
return parser_memhash((const void *)PARSER_STRING_PTR(str), PARSER_STRING_LEN(str));
}

static size_t
rb_parser_str_capacity(rb_parser_string_t *str, const int termlen)
{
Expand Down

0 comments on commit a669207

Please sign in to comment.