diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-05-05 13:16:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 13:16:25 +0200 |
commit | 45a4d75296b221240a2842bae0aef21622e21f97 (patch) | |
tree | a0af348a54099f9dd2b2be34c1e071375bc99d6d /cli | |
parent | 242273e69b5f5add23393e8e96e241696eae88fb (diff) |
refactor(core): use Box<u8> for ModuleSource.code instead of a String (#14487)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/proc_state.rs | 5 | ||||
-rw-r--r-- | cli/standalone.rs | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index d4173ee2e..8df68d15b 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -592,7 +592,7 @@ impl ProcState { } }; Ok(ModuleSource { - code, + code: code.into_bytes().into_boxed_slice(), module_url_specified: specifier.to_string(), module_url_found: found.to_string(), module_type: match media_type { @@ -646,7 +646,8 @@ impl SourceMapGetter for ProcState { let code = String::from_utf8(code).unwrap(); source_map_from_code(code).or(maybe_map) } else if let Ok(source) = self.load(specifier, None, false) { - source_map_from_code(source.code) + let code = String::from_utf8(source.code.to_vec()).unwrap(); + source_map_from_code(code) } else { None } diff --git a/cli/standalone.rs b/cli/standalone.rs index 1d75734be..13bc3e70f 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -168,9 +168,9 @@ impl ModuleLoader for EmbeddedModuleLoader { .ok_or_else(|| type_error("Module not found")); async move { - if let Some((ref source, _)) = is_data_uri { + if let Some((source, _)) = is_data_uri { return Ok(deno_core::ModuleSource { - code: source.to_owned(), + code: source.into_bytes().into_boxed_slice(), module_type: deno_core::ModuleType::JavaScript, module_url_specified: module_specifier.to_string(), module_url_found: module_specifier.to_string(), @@ -184,7 +184,7 @@ impl ModuleLoader for EmbeddedModuleLoader { .to_owned(); Ok(deno_core::ModuleSource { - code, + code: code.into_bytes().into_boxed_slice(), module_type: match module.kind { eszip::ModuleKind::JavaScript => deno_core::ModuleType::JavaScript, eszip::ModuleKind::Json => deno_core::ModuleType::Json, |