From 0b4770fa7daf274ab01923fb09fd604aeb27e417 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Tue, 21 Mar 2023 16:33:12 -0600 Subject: perf(core) Reduce script name and script code copies (#18298) Reduce the number of copies and allocations of script code by carrying around ownership/reference information from creation time. As an advantage, this allows us to maintain the identity of `&'static str`-based scripts and use v8's external 1-byte strings (to avoid incorrectly passing non-ASCII strings, debug `assert!`s gate all string reference paths). Benchmark results: Perf improvements -- ~0.1 - 0.2ms faster, but should reduce garbage w/external strings and reduces data copies overall. May also unlock some more interesting optimizations in the future. This requires adding some generics to functions, but manual monomorphization has been applied (outer/inner function) to avoid code bloat. --- core/examples/ts_module_loader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/examples/ts_module_loader.rs') diff --git a/core/examples/ts_module_loader.rs b/core/examples/ts_module_loader.rs index c7097fc91..4a38073ab 100644 --- a/core/examples/ts_module_loader.rs +++ b/core/examples/ts_module_loader.rs @@ -82,7 +82,7 @@ impl ModuleLoader for TypescriptModuleLoader { code }; let module = ModuleSource { - code: code.into_bytes().into_boxed_slice(), + code: code.into(), module_type, module_url_specified: module_specifier.to_string(), module_url_found: module_specifier.to_string(), -- cgit v1.2.3