diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-03-21 12:13:32 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 12:13:32 -0600 |
commit | a561cc28cd59b51846fce9a9de598e2fd6e9b54e (patch) | |
tree | bb1d7e69e90d465447f541f100630c5e5fc4bf3d /cli/args/mod.rs | |
parent | 0d27de943a60f5ca60e2116648719c235163361a (diff) |
chore(cli) Use with_context(|| format!(...)) rather than context(format!(...)) to avoid allocations in non-error path (#18332)
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index a624dcc79..848f50eb4 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -669,9 +669,9 @@ impl CliOptions { file_fetcher, ) .await - .context(format!( - "Unable to load '{import_map_specifier}' import map" - )) + .with_context(|| { + format!("Unable to load '{import_map_specifier}' import map") + }) .map(Some) } @@ -1091,7 +1091,9 @@ fn resolve_import_map_specifier( } let specifier = deno_core::resolve_url_or_path(import_map_path, current_dir) - .context(format!("Bad URL (\"{import_map_path}\") for import map."))?; + .with_context(|| { + format!("Bad URL (\"{import_map_path}\") for import map.") + })?; return Ok(Some(specifier)); } else if let Some(config_file) = &maybe_config_file { // if the config file is an import map we prefer to use it, over `importMap` @@ -1131,7 +1133,7 @@ fn resolve_import_map_specifier( // use "import resolution" with the config file as the base. } else { deno_core::resolve_import(&import_map_path, config_file.specifier.as_str()) - .context(format!( + .with_context(|| format!( "Bad URL (\"{import_map_path}\") for import map." ))? }; |