From 568c9814c176bce25f60ec60fe67884c444caf1e Mon Sep 17 00:00:00 2001 From: Vedat Can Keklik Date: Mon, 16 Dec 2024 15:39:37 +0300 Subject: [PATCH] fix: Simpler read --- lykiadb-server/src/value/environment.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lykiadb-server/src/value/environment.rs b/lykiadb-server/src/value/environment.rs index 3f78af8..e8934c9 100644 --- a/lykiadb-server/src/value/environment.rs +++ b/lykiadb-server/src/value/environment.rs @@ -84,9 +84,10 @@ impl EnvironmentFrame { } pub fn read(&self, key: &str, key_sym: &SymbolU32) -> Result { - if self.map.read().unwrap().contains_key(key_sym) { + let guard = self.map.read().unwrap(); + if let Some(value) = guard.get(key_sym) { // TODO(vck): Remove clone - return Ok(self.map.read().unwrap().get(key_sym).unwrap().clone()); + return Ok(value.clone()); } self.parent.as_ref().map_or( Err(HaltReason::Error(