diff --git a/cli/startup_data.rs b/cli/startup_data.rs index 62a54d8564717a..1a77915e9004fc 100644 --- a/cli/startup_data.rs +++ b/cli/startup_data.rs @@ -11,8 +11,8 @@ pub fn deno_isolate_init() -> StartupData<'static> { let source_bytes = vec![]; StartupData::Script(Script { - filename: "gen/cli/bundle/main.js".to_string(), - source: std::str::from_utf8(&source_bytes[..]).unwrap().to_string(), + filename: "gen/cli/bundle/main.js", + source: std::str::from_utf8(&source_bytes[..]).unwrap(), }) } else { debug!("Deno isolate init with snapshots."); @@ -38,8 +38,8 @@ pub fn compiler_isolate_init() -> StartupData<'static> { let source_bytes = vec![]; StartupData::Script(Script { - filename: "gen/cli/bundle/compiler.js".to_string(), - source: std::str::from_utf8(&source_bytes[..]).unwrap().to_string(), + filename: "gen/cli/bundle/compiler.js", + source: std::str::from_utf8(&source_bytes[..]).unwrap(), }) } else { debug!("Deno isolate init with snapshots."); diff --git a/core/http_bench.rs b/core/http_bench.rs index cb4e0ac50a49d4..fced92bf837174 100644 --- a/core/http_bench.rs +++ b/core/http_bench.rs @@ -163,8 +163,8 @@ fn main() { let js_source = include_str!("http_bench.js"); let startup_data = StartupData::Script(Script { - source: js_source.to_string(), - filename: "http_bench.js".to_string(), + source: js_source, + filename: "http_bench.js", }); let isolate = deno::Isolate::new(startup_data, HttpBench()); diff --git a/core/isolate.rs b/core/isolate.rs index 938c0c63149ea8..88f42be0e941b9 100644 --- a/core/isolate.rs +++ b/core/isolate.rs @@ -51,16 +51,16 @@ impl Future for PendingOp { } /// Stores a script used to initalize a Isolate -pub struct Script { - pub source: String, - pub filename: String, +pub struct Script<'a> { + pub source: &'a str, + pub filename: &'a str, } /// Represents data used to initialize isolate at startup /// either a binary snapshot or a javascript source file /// in the form of the StartupScript struct. pub enum StartupData<'a> { - Script(Script), + Script(Script<'a>), Snapshot(&'a [u8]), None, } @@ -149,9 +149,7 @@ impl Isolate { // If we want to use execute this has to happen here sadly. if let Some(s) = startup_script { - core_isolate - .execute(s.filename.as_str(), s.source.as_str()) - .unwrap() + core_isolate.execute(s.filename, s.source).unwrap() }; core_isolate