summaryrefslogtreecommitdiff
path: root/cli/build.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-12-03 03:07:04 +0100
committerGitHub <noreply@github.com>2023-12-03 02:07:04 +0000
commit39c7d8dafe00fd619afac7de0151790e7d53cd43 (patch)
tree3881a0cf6b92090a8d8a1457354bd8f9d26d8a70 /cli/build.rs
parentf6b889b43219e3c9be770c8b2758bff3048ddcbd (diff)
refactor: faster args for op_load in TSC (#21438)
This commit changes the argument that "op_load" accepts, from a serde struct to "&str". This should equal to a slightly better performance.
Diffstat (limited to 'cli/build.rs')
-rw-r--r--cli/build.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/cli/build.rs b/cli/build.rs
index edb2e4fdd..4400e3e8b 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -13,18 +13,11 @@ mod ts {
use deno_core::op2;
use deno_core::OpState;
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
- use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;
- #[derive(Debug, Deserialize)]
- struct LoadArgs {
- /// The fully qualified specifier that should be loaded.
- specifier: String,
- }
-
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct BuildInfoResponse {
@@ -81,7 +74,7 @@ mod ts {
// files, but a slightly different implementation at build time.
fn op_load(
state: &mut OpState,
- #[serde] args: LoadArgs,
+ #[string] load_specifier: &str,
) -> Result<LoadResponse, AnyError> {
let op_crate_libs = state.borrow::<HashMap<&str, PathBuf>>();
let path_dts = state.borrow::<PathBuf>();
@@ -89,7 +82,7 @@ mod ts {
let build_specifier = "asset:///bootstrap.ts";
// we need a basic file to send to tsc to warm it up.
- if args.specifier == build_specifier {
+ if load_specifier == build_specifier {
Ok(LoadResponse {
data: r#"Deno.writeTextFile("hello.txt", "hello deno!");"#.to_string(),
version: "1".to_string(),
@@ -98,7 +91,7 @@ mod ts {
})
// specifiers come across as `asset:///lib.{lib_name}.d.ts` and we need to
// parse out just the name so we can lookup the asset.
- } else if let Some(caps) = re_asset.captures(&args.specifier) {
+ } else if let Some(caps) = re_asset.captures(load_specifier) {
if let Some(lib) = caps.get(1).map(|m| m.as_str()) {
// if it comes from an op crate, we were supplied with the path to the
// file.
@@ -118,13 +111,13 @@ mod ts {
} else {
Err(custom_error(
"InvalidSpecifier",
- format!("An invalid specifier was requested: {}", args.specifier),
+ format!("An invalid specifier was requested: {}", load_specifier),
))
}
} else {
Err(custom_error(
"InvalidSpecifier",
- format!("An invalid specifier was requested: {}", args.specifier),
+ format!("An invalid specifier was requested: {}", load_specifier),
))
}
}