diff options
author | pavel <pavel.rosicky@easy.cz> | 2019-07-19 16:23:00 +0200 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-28 11:29:49 +0900 |
commit | 8e13da1ee83028000e5d7f9f9526379e32765a81 (patch) | |
tree | 2ac2cac18839da9817632d3427a1b5f317cc9674 | |
parent | 989e8ad322afdfa3aa06e74b89fc42aef42895d0 (diff) |
optimize get_power2 [Feature #15631]
Merged: https://github.com/ruby/ruby/pull/2292
-rw-r--r-- | st.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -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 |