apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1672575 - /apr/apr/trunk/tables/apr_skiplist.c
Date Fri, 10 Apr 2015 07:51:08 GMT
Author: ylavic
Date: Fri Apr 10 07:51:08 2015
New Revision: 1672575

URL: http://svn.apache.org/r1672575
Log:
skiplist: avoid (undefined) unsigned to signed conversion and save cycles in
the hot path get_b_rand().

Modified:
    apr/apr/trunk/tables/apr_skiplist.c

Modified: apr/apr/trunk/tables/apr_skiplist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_skiplist.c?rev=1672575&r1=1672574&r2=1672575&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_skiplist.c (original)
+++ apr/apr/trunk/tables/apr_skiplist.c Fri Apr 10 07:51:08 2015
@@ -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 {



Mime
View raw message