Skip to content

Commit

Permalink
optimize get_power2 [Feature #15631]
Browse files Browse the repository at this point in the history
Merged: #2292
  • Loading branch information
ahorek authored and nobu committed Aug 28, 2019
1 parent 989e8ad commit 8e13da1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions st.c
Expand Up @@ -345,10 +345,7 @@ do_hash(st_data_t key, st_table *tab)
static int
get_power2(st_index_t size)
{
unsigned int n;

for (n = 0; size != 0; n++)
size >>= 1;
unsigned int n = ST_INDEX_BITS - nlz_intptr(size);
if (n <= MAX_POWER2)
return n < MINIMAL_POWER2 ? MINIMAL_POWER2 : n;
#ifndef NOT_RUBY
Expand Down

0 comments on commit 8e13da1

Please sign in to comment.