From 9c340ea08ce6e3ceeecbce35276b49d082820bda Mon Sep 17 00:00:00 2001 From: Jordan Johnson-Doyle Date: Thu, 14 Feb 2019 01:24:24 +0000 Subject: [PATCH] Only need to read from BIN_BUFFER_SIZE once --- src/io.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/io.rs b/src/io.rs index 6b6a343..f72783a 100644 --- a/src/io.rs +++ b/src/io.rs @@ -9,6 +9,7 @@ use std::cell::RefCell; lazy_static! { static ref ENTRIES: RwLock> = RwLock::new(LinkedHashMap::new()); + static ref BUFFER_SIZE: usize = env::var("BIN_BUFFER_SIZE").map(|f| f.parse::().unwrap()).unwrap_or(1000usize); } /// Ensures `ENTRIES` is less than the size of `BIN_BUFFER_SIZE`. If it isn't then @@ -17,10 +18,9 @@ lazy_static! { /// During the purge, `ENTRIES` is locked and the current thread will block. fn purge_old() { let entries_len = ENTRIES.read().unwrap().len(); - let buffer_size = env::var("BIN_BUFFER_SIZE").map(|f| f.parse::().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(); -- libgit2 1.7.2