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. --- cli/tools/coverage/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cli/tools/coverage/mod.rs') diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index 2346b3614..7f2598811 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -691,7 +691,7 @@ pub async fn cover_files( | MediaType::Unknown | MediaType::Cjs | MediaType::Mjs - | MediaType::Json => file.source.into(), + | MediaType::Json => file.source.clone().into(), MediaType::Dts | MediaType::Dmts | MediaType::Dcts => Default::default(), MediaType::TypeScript | MediaType::Jsx @@ -718,7 +718,7 @@ pub async fn cover_files( let source_map = source_map_from_code(&transpiled_code); let coverage_report = generate_coverage_report( &script_coverage, - transpiled_code.take_as_string(), + transpiled_code.as_str().to_owned(), &source_map, &out_mode, ); -- cgit v1.2.3