diff options
author | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-04-10 07:55:39 +0000 |
---|---|---|
committer | ylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68> | 2015-04-10 07:55:39 +0000 |
commit | 236cf5f2b5b03a161bbff35fd8d3876f026fb9c0 (patch) | |
tree | 52fe78109e2f2c6cabdf0f6d158e18880a8edc2f | |
parent | 7a053d28a89eb1993a8287cc47af5a8cb70dcdc1 (diff) | |
download | libapr-236cf5f2b5b03a161bbff35fd8d3876f026fb9c0.tar.gz |
Merge r1672575 from trunk.
skiplist: avoid (undefined) unsigned to signed conversion and save cycles in
the hot path get_b_rand().
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1672577 13f79535-47bb-0310-9956-ffa450edef68
-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 a61ec25a3..b4696bd41 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 { |