Unverified Commit e5326844 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: remove a few clones (#82435)

Showed up in an ast-grep search for `&$$$.clone()`
parent 4dd7c7fa
...@@ -23,7 +23,7 @@ impl Task for CheckTask { ...@@ -23,7 +23,7 @@ impl Task for CheckTask {
GLOBALS.set(&Default::default(), || { GLOBALS.set(&Default::default(), || {
// //
let cm = Arc::new(SourceMap::default()); let cm = Arc::new(SourceMap::default());
let Ok(fm) = cm.load_file(&self.filename.clone()) else { let Ok(fm) = cm.load_file(&self.filename) else {
return Ok(false); return Ok(false);
}; };
let mut errors = vec![]; let mut errors = vec![];
......
...@@ -1392,7 +1392,7 @@ async fn find_package( ...@@ -1392,7 +1392,7 @@ async fn find_package(
for name in names.iter() { for name in names.iter() {
let fs_path = lookup_path.join(name)?; let fs_path = lookup_path.join(name)?;
if let Some(fs_path) = dir_exists(fs_path, &mut affecting_sources).await? { if let Some(fs_path) = dir_exists(fs_path, &mut affecting_sources).await? {
let fs_path = fs_path.join(&package_name.clone())?; let fs_path = fs_path.join(&package_name)?;
if let Some(fs_path) = if let Some(fs_path) =
dir_exists(fs_path.clone(), &mut affecting_sources).await? dir_exists(fs_path.clone(), &mut affecting_sources).await?
{ {
...@@ -1431,7 +1431,7 @@ async fn find_package( ...@@ -1431,7 +1431,7 @@ async fn find_package(
if excluded_extensions.contains(extension) { if excluded_extensions.contains(extension) {
continue; continue;
} }
let package_file = package_dir.append(&extension.clone())?; let package_file = package_dir.append(extension)?;
if let Some(package_file) = exists(package_file, &mut affecting_sources).await? if let Some(package_file) = exists(package_file, &mut affecting_sources).await?
{ {
packages.push(FindPackageItem::PackageFile(package_file)); packages.push(FindPackageItem::PackageFile(package_file));
......
...@@ -1631,7 +1631,7 @@ pub async fn read_matches( ...@@ -1631,7 +1631,7 @@ pub async fn read_matches(
prefix.pop(); prefix.pop();
} }
if let Some(pos) = pat.match_position(&prefix) { if let Some(pos) = pat.match_position(&prefix) {
let fs_path = lookup_dir.join(&key.clone())?; let fs_path = lookup_dir.join(key)?;
if let LinkContent::Link { link_type, .. } = if let LinkContent::Link { link_type, .. } =
&*fs_path.read_link().await? &*fs_path.read_link().await?
{ {
...@@ -1653,7 +1653,7 @@ pub async fn read_matches( ...@@ -1653,7 +1653,7 @@ pub async fn read_matches(
} }
prefix.push('/'); prefix.push('/');
if let Some(pos) = pat.match_position(&prefix) { if let Some(pos) = pat.match_position(&prefix) {
let fs_path = lookup_dir.join(&key.clone())?; let fs_path = lookup_dir.join(key)?;
if let LinkContent::Link { link_type, .. } = if let LinkContent::Link { link_type, .. } =
&*fs_path.read_link().await? &*fs_path.read_link().await?
&& link_type.contains(LinkType::DIRECTORY) && link_type.contains(LinkType::DIRECTORY)
...@@ -1665,7 +1665,7 @@ pub async fn read_matches( ...@@ -1665,7 +1665,7 @@ pub async fn read_matches(
} }
} }
if let Some(pos) = pat.could_match_position(&prefix) { if let Some(pos) = pat.could_match_position(&prefix) {
let fs_path = lookup_dir.join(&key.clone())?; let fs_path = lookup_dir.join(key)?;
if let LinkContent::Link { link_type, .. } = if let LinkContent::Link { link_type, .. } =
&*fs_path.read_link().await? &*fs_path.read_link().await?
&& link_type.contains(LinkType::DIRECTORY) && link_type.contains(LinkType::DIRECTORY)
......
...@@ -127,7 +127,7 @@ impl GetContentSourceContent for NodeApiContentSource { ...@@ -127,7 +127,7 @@ impl GetContentSourceContent for NodeApiContentSource {
Ok(ContentSourceContent::HttpProxy(render_proxy_operation( Ok(ContentSourceContent::HttpProxy(render_proxy_operation(
self.cwd.clone(), self.cwd.clone(),
self.env, self.env,
self.server_root.join(&path.clone())?, self.server_root.join(&path)?,
ResolvedVc::upcast(entry.module), ResolvedVc::upcast(entry.module),
entry.runtime_entries, entry.runtime_entries,
entry.chunking_context, entry.chunking_context,
......
...@@ -291,8 +291,8 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> { ...@@ -291,8 +291,8 @@ async fn prepare_test(resource: RcStr) -> Result<Vc<PreparedTest>> {
resource_path.display() resource_path.display()
))?; ))?;
let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into(); let relative_path: RcStr = sys_to_unix(relative_path.to_str().unwrap()).into();
let path = root_fs.root().await?.join(&relative_path.clone())?; let path = root_fs.root().await?.join(&relative_path)?;
let project_path = project_root.join(&relative_path.clone())?; let project_path = project_root.join(&relative_path)?;
let tests_path = project_fs let tests_path = project_fs
.root() .root()
.await? .await?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment