• Oran Agra's avatar
    Optimize HRANDFIELD and ZRANDMEMBER case 4 when ziplist encoded (#8444) · 62b1f320
    Oran Agra authored
    
    
    It is inefficient to repeatedly pick a single random element from a
    ziplist.
    For CASE4, which is when the user requested a low number of unique
    random picks from the collectoin, we used thta pattern.
    
    Now we use a different algorithm that picks unique elements from a
    ziplist, and guarentee no duplicate but doesn't provide random order
    (which is only needed in the non-unique random picks case)
    
    Unrelated changes:
    * change ziplist count and indexes variables to unsigned
    * solve compilation warnings about uninitialized vars in gcc 10.2
    Co-authored-by: default avatarxinluton <xinluton@qq.com>
    62b1f320
ziplist.h 3.72 KB