Only need to read from BIN_BUFFER_SIZE once
Diff
src/io.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -9,6 +9,7 @@
lazy_static! {
static ref ENTRIES: RwLock<LinkedHashMap<String, String>> = RwLock::new(LinkedHashMap::new());
static ref BUFFER_SIZE: usize = env::var("BIN_BUFFER_SIZE").map(|f| f.parse::<usize>().unwrap()).unwrap_or(1000usize);
}
@@ -17,10 +18,9 @@
fn purge_old() {
let entries_len = ENTRIES.read().unwrap().len();
let buffer_size = env::var("BIN_BUFFER_SIZE").map(|f| f.parse::<usize>().unwrap()).unwrap_or(1000usize);
if entries_len > buffer_size {
let to_remove = entries_len - buffer_size;
if entries_len > *BUFFER_SIZE {
let to_remove = entries_len - *BUFFER_SIZE;
let mut entries = ENTRIES.write().unwrap();