From a31d8869ea6c0651109523963a23f16101ce7e64 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 Feb 2023 18:22:24 -0500 Subject: perf: remove `current_dir()` call in `Deno.mainModule` (#17883) --- runtime/ops/runtime.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'runtime/ops') 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 { - let main = state.borrow::().to_string(); - let main_url = deno_core::resolve_url_or_path(&main)?; + let main_url = state.borrow::(); + 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::() .check_read_blind(&main_path, "main_module", "Deno.mainModule")?; } - Ok(main) + Ok(main_path) } pub fn ppid() -> i64 { -- cgit v1.2.3