summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2015-04-10 07:51:08 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2015-04-10 07:51:08 +0000
commit9fa81f73a0a452ef763fdc8e675be55d74ba8091 (patch)
tree725d489fa2eeb14e75003fdf4d77b7aca8689661 /tables
parent95d600914cf36c75e4971eb6e5f119c5bb107fba (diff)
downloadlibapr-9fa81f73a0a452ef763fdc8e675be55d74ba8091.tar.gz
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/trunk@1672575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_skiplist.c7
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 {