al8n / stretto

Stretto is a Rust implementation for Dgraph's ristretto (https://github.com/dgraph-io/ristretto). A high performance memory-bound Rust cache.
Apache License 2.0
413 stars 28 forks source link

Specify number of entries parameter as (usize) integer #51

Closed peter-scholtens closed 1 year ago

peter-scholtens commented 1 year ago

While reviewing the code I was a confused by the name num_entries which suggest an integer while actually a fractional number is used. Changing this to usize and shadowing num_items locally makes the function call 7 machine code instructions shorter and the function body longer 5 instructions longer (from 65 to 70, as checked by the compiler explorer). So with improved code readability also 2 instructions less are needed.