diff options
author | Yann Ylavic <ylavic@apache.org> | 2015-04-10 07:51:08 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2015-04-10 07:51:08 +0000 |
commit | b04bac484410851319c44463b87c1d15f8bbc455 (patch) | |
tree | 725d489fa2eeb14e75003fdf4d77b7aca8689661 /tables | |
parent | 085003fdcce220fbe1230d7c3ee0aad84f97ec38 (diff) | |
download | apr-b04bac484410851319c44463b87c1d15f8bbc455.tar.gz |
skiplist: avoid (undefined) unsigned to signed conversion and save cycles in
the hot path get_b_rand().
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1672575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r-- | tables/apr_skiplist.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tables/apr_skiplist.c b/tables/apr_skiplist.c index b5027ecf7..5ea8643db 100644 --- a/tables/apr_skiplist.c +++ b/tables/apr_skiplist.c @@ -63,13 +63,12 @@ struct apr_skiplistnode { static int get_b_rand(void) { static int ph = 32; /* More bits than we will ever use */ - static apr_uint32_t randseq; + static int randseq; if (ph > 31) { /* Num bits in return of rand() */ ph = 0; - randseq = (apr_uint32_t) rand(); + randseq = rand(); } - ph++; - return ((randseq & (1 << (ph - 1))) >> (ph - 1)); + return randseq & (1 << ph++); } typedef struct { |