refactor(cli,core,ext,rt): remove some unnecessary clone or malloc (#17274)

This commit is contained in:
Yiyu Lin 2023-01-06 03:29:50 +08:00 committed by GitHub
parent 4e6b78cb43
commit 896dd56b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 86 additions and 72 deletions

View file

@ -58,7 +58,7 @@ pub fn check(
roots: &[(ModuleSpecifier, ModuleKind)],
graph_data: Arc<RwLock<GraphData>>,
cache: &TypeCheckCache,
npm_resolver: NpmPackageResolver,
npm_resolver: &NpmPackageResolver,
options: CheckOptions,
) -> Result<CheckResult, AnyError> {
let check_js = options.ts_config.get_check_js();

View file

@ -183,5 +183,5 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
}
}
Ok(repl_session.worker.get_exit_code())
Ok(repl_session.worker.exit_code())
}

View file

@ -242,7 +242,7 @@ impl VendorTestBuilder {
let import_map = files.remove(&output_dir.join("import_map.json"));
let mut files = files
.iter()
.map(|(path, text)| (path_to_string(path), text.clone()))
.map(|(path, text)| (path_to_string(path), text.to_string()))
.collect::<Vec<_>>();
files.sort_by(|a, b| a.0.cmp(&b.0));
@ -293,7 +293,11 @@ fn make_path(text: &str) -> PathBuf {
}
}
fn path_to_string(path: &Path) -> String {
fn path_to_string<P>(path: P) -> String
where
P: AsRef<Path>,
{
let path = path.as_ref();
// inverse of the function above
let path = path.to_string_lossy();
if cfg!(windows) {