optimize get_power2 [Feature #15631]
Merged: https://github.com/ruby/ruby/pull/2292
This commit is contained in:
parent
989e8ad322
commit
8e13da1ee8
5
st.c
5
st.c
@ -345,10 +345,7 @@ do_hash(st_data_t key, st_table *tab)
|
|||||||
static int
|
static int
|
||||||
get_power2(st_index_t size)
|
get_power2(st_index_t size)
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned int n = ST_INDEX_BITS - nlz_intptr(size);
|
||||||
|
|
||||||
for (n = 0; size != 0; n++)
|
|
||||||
size >>= 1;
|
|
||||||
if (n <= MAX_POWER2)
|
if (n <= MAX_POWER2)
|
||||||
return n < MINIMAL_POWER2 ? MINIMAL_POWER2 : n;
|
return n < MINIMAL_POWER2 ? MINIMAL_POWER2 : n;
|
||||||
#ifndef NOT_RUBY
|
#ifndef NOT_RUBY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user