From 64ee21ec86b3b8b0d35256b823f0e6c9670a9acc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 17 May 2023 18:41:52 +0300 Subject: [PATCH] chore(tvix/cli): remove unnecessary RefCell This remained around from some previous time where this type was being cloned around directly, but it's not anymore. Change-Id: I2c61cf9cecb8e5d7d08644ed20642ee61357bc21 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8580 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/cli/src/nix_compat.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tvix/cli/src/nix_compat.rs b/tvix/cli/src/nix_compat.rs index 70bddb834..4141e0a21 100644 --- a/tvix/cli/src/nix_compat.rs +++ b/tvix/cli/src/nix_compat.rs @@ -5,7 +5,6 @@ //! by piggybacking off functionality that already exists in Nix and //! is still being implemented in Tvix. -use std::cell::RefCell; use std::collections::HashMap; use std::path::Path; use std::process::Command; @@ -25,7 +24,7 @@ pub struct NixCompatIO { // TODO(tazjin): This could be done better by having a thunk cache // for these calls on the eval side, but that is a little more // complex. - import_cache: RefCell>, + import_cache: HashMap, } impl EvalIO for NixCompatIO { @@ -36,7 +35,7 @@ impl EvalIO for NixCompatIO { // Pass path imports through to `nix-store --add` fn import_path(&mut self, path: &Path) -> Result { let path = path.to_owned(); - if let Some(path) = self.import_cache.borrow().get(&path) { + if let Some(path) = self.import_cache.get(&path) { return Ok(path.to_path_buf()); } @@ -45,9 +44,8 @@ impl EvalIO for NixCompatIO { path: Some(path.to_path_buf()), })?; - self.import_cache - .borrow_mut() - .insert(path, store_path.clone()); + self.import_cache.insert(path, store_path.clone()); + Ok(store_path) } @@ -83,7 +81,7 @@ impl NixCompatIO { pub fn new() -> Self { NixCompatIO { underlying: StdIO, - import_cache: RefCell::new(HashMap::new()), + import_cache: HashMap::new(), } }