diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-22 18:22:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 18:22:24 -0500 |
commit | a31d8869ea6c0651109523963a23f16101ce7e64 (patch) | |
tree | 7172dbcb3faaa2a3721414baeb9198a00b694ff0 /runtime/ops/runtime.rs | |
parent | 1c14127c4f54d815b3e1be48bddd5198dcb33a50 (diff) |
perf: remove `current_dir()` call in `Deno.mainModule` (#17883)
Diffstat (limited to 'runtime/ops/runtime.rs')
-rw-r--r-- | runtime/ops/runtime.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index 70814e3b8..22a481e77 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -1,7 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::permissions::PermissionsContainer; -use deno_core::anyhow::Context; use deno_core::error::AnyError; use deno_core::op; use deno_core::Extension; @@ -20,17 +19,15 @@ pub fn init(main_module: ModuleSpecifier) -> Extension { #[op] fn op_main_module(state: &mut OpState) -> Result<String, AnyError> { - let main = state.borrow::<ModuleSpecifier>().to_string(); - let main_url = deno_core::resolve_url_or_path(&main)?; + let main_url = state.borrow::<ModuleSpecifier>(); + let main_path = main_url.to_string(); if main_url.scheme() == "file" { - let main_path = std::env::current_dir() - .context("Failed to get current working directory")? - .join(main_url.to_string()); + let main_path = main_url.to_file_path().unwrap(); state .borrow_mut::<PermissionsContainer>() .check_read_blind(&main_path, "main_module", "Deno.mainModule")?; } - Ok(main) + Ok(main_path) } pub fn ppid() -> i64 { |