From a1764f7690cfdc3e42724fcad29ef954b7e576a4 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Tue, 4 Apr 2023 06:46:31 -0600 Subject: refactor(core): Improve ergonomics of managing ASCII strings (#18498) This is a follow-on to the earlier work in reducing string copies, mainly focused on ensuring that ASCII strings are easy to provide to the JS runtime. While we are replacing a 16-byte reference in a number of places with a 24-byte structure (measured via `std::mem::size_of`), the reduction in copies wins out over the additional size of the arguments passed into functions. Benchmarking shows approximately the same if not slightly less wallclock time/instructions retired, but I believe this continues to open up further refactoring opportunities. --- ext/node/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/node/lib.rs b/ext/node/lib.rs index f3bdb7e5b..7bf721f0a 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -447,7 +447,7 @@ pub fn initialize_runtime( argv0 ); - js_runtime.execute_script(located_script_name!(), source_code)?; + js_runtime.execute_script(located_script_name!(), source_code.into())?; Ok(()) } @@ -468,7 +468,8 @@ pub fn load_cjs_module( main = main, module = escape_for_single_quote_string(module), inspect_brk = inspect_brk, - ); + ) + .into(); js_runtime.execute_script(located_script_name!(), source_code)?; Ok(()) -- cgit v1.2.3