From 6ae91d8e46613cc887b48be0a42723550082cd2c Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Tue, 5 Jul 2022 17:23:40 +0800 Subject: [PATCH] pddb: make select_basis and latest_basis non-mut These do not need to clone data and do not need to be mut. This improves access time considerably. Signed-off-by: Sean Cross --- services/pddb/src/backend/basis.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/pddb/src/backend/basis.rs b/services/pddb/src/backend/basis.rs index 62a6fe862..5e4bfe337 100644 --- a/services/pddb/src/backend/basis.rs +++ b/services/pddb/src/backend/basis.rs @@ -268,7 +268,7 @@ impl BasisCache { } al } - fn select_basis(&mut self, basis_name: Option<&str>) -> Option { + fn select_basis(&self, basis_name: Option<&str>) -> Option { if self.cache.len() == 0 { log::error!("Can't select basis: PDDB is not mounted"); return None @@ -895,10 +895,10 @@ impl BasisCache { } ret } - pub(crate) fn basis_latest(&mut self) -> Option { + pub(crate) fn basis_latest(&self) -> Option<&str> { if let Some(basis_index) = self.select_basis(None) { - let basis = &mut self.cache[basis_index]; - Some(basis.name.clone()) + let basis = &self.cache[basis_index]; + Some(&basis.name) } else { None }