From 5b4a9b48aeabded174cc161bfdafb6529cffbca1 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 24 Apr 2023 21:07:48 -0400 Subject: refactor(ext/node): enforce interior mutable for `NodePermissions` to remove clones (#18831) We can make `NodePermissions` rely on interior mutability (which the `PermissionsContainer` is already doing) in order to not have to clone everything all the time. This also reduces the chance of an accidental `borrow` while `borrrow_mut`. --- runtime/build.rs | 5 +---- runtime/permissions/mod.rs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/build.rs b/runtime/build.rs index 358a30dc5..2f3b12595 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -122,10 +122,7 @@ mod startup_snapshot { } impl deno_node::NodePermissions for Permissions { - fn check_read( - &mut self, - _p: &Path, - ) -> Result<(), deno_core::error::AnyError> { + fn check_read(&self, _p: &Path) -> Result<(), deno_core::error::AnyError> { unreachable!("snapshotting!") } } diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs index b15750313..6cce7d1e9 100644 --- a/runtime/permissions/mod.rs +++ b/runtime/permissions/mod.rs @@ -1872,7 +1872,7 @@ impl PermissionsContainer { impl deno_node::NodePermissions for PermissionsContainer { #[inline(always)] - fn check_read(&mut self, path: &Path) -> Result<(), AnyError> { + fn check_read(&self, path: &Path) -> Result<(), AnyError> { self.0.lock().read.check(path, None) } } -- cgit v1.2.3