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/util/text_encoding.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cli/util/text_encoding.rs') diff --git a/cli/util/text_encoding.rs b/cli/util/text_encoding.rs index 0111ec82f..29a8d4069 100644 --- a/cli/util/text_encoding.rs +++ b/cli/util/text_encoding.rs @@ -160,7 +160,9 @@ mod tests { fn run_test(input: &'static str, output: &'static str) { assert_eq!( - code_without_source_map(input.into()).take_as_string(), + code_without_source_map(ModuleCode::from_static(input)) + .as_str() + .to_owned(), output ); } -- cgit v1.2.3