X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Fskiplist.c;h=d073287462e6924fa37298693ae9b5ed62c32659;hb=56c8b099ccef8240d76c6f88c3f31d86ae22cfba;hp=9f21ce72bff63c87490b1523bb06d6cb4bd3ecdf;hpb=fef249060579771eb4f43bfb4cd7ebe827c6a633;p=sxemacs diff --git a/src/skiplist.c b/src/skiplist.c index 9f21ce7..d073287 100644 --- a/src/skiplist.c +++ b/src/skiplist.c @@ -46,6 +46,8 @@ #include "lrecord.h" #include "lstream.h" +/* for __ase_ffs() */ +#include "ent/ent.h" #include "skiplist.h" #define __SKIPLIST_DEBUG__(args...) fprintf(stderr, "SKIPLIST " args) @@ -113,8 +115,6 @@ static inline skiplist_level_t skiplist_find_hash_return_level(skiplist_t, hcode_t) __attribute__((always_inline)); -extern int get_random(void); - /* high level bindings */ /* low level bindings */ @@ -561,8 +561,10 @@ _put_skiplist(skiplist_t sl, skiplist_level_t *path, size_t psz, hcode_t h, Lisp_Object key, Lisp_Object value) { /* entirely new data, build a node for it */ - /* determine the number of levels to add */ - size_t nlevels = __ase_ffsl(random()), cnt; + /* determine the number of levels to add, this is a log distribution + * so we use ffs(3) of a random number */ + size_t nlevels = __ase_ffsl(random()); + size_t cnt; skiplist_level_t levels, last = path[psz--]; skiplist_node_t node;