Skip to content

Commit 2c88a63

Browse files
author
Jon Gjengset
committed
Remove Cow over-optimization
1 parent ce0b8e8 commit 2c88a63

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/cargo/core/workspace.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::borrow::Cow;
21
use std::cell::RefCell;
32
use std::collections::hash_map::{Entry, HashMap};
43
use std::collections::{BTreeMap, BTreeSet, HashSet};
@@ -366,7 +365,7 @@ impl<'cfg> Workspace<'cfg> {
366365
/// Returns the root `[patch]` section of this workspace.
367366
///
368367
/// This may be from a virtual crate or an actual crate.
369-
pub fn root_patch(&self) -> Cow<'_, HashMap<Url, Vec<Dependency>>> {
368+
pub fn root_patch(&self) -> HashMap<Url, Vec<Dependency>> {
370369
let from_manifest = match self.root_maybe() {
371370
MaybePackage::Package(p) => p.manifest().patch(),
372371
MaybePackage::Virtual(vm) => vm.patch(),
@@ -377,10 +376,10 @@ impl<'cfg> Workspace<'cfg> {
377376
.patch()
378377
.expect("config [patch] was never parsed");
379378
if from_config.is_empty() {
380-
return Cow::Borrowed(from_manifest);
379+
return from_manifest.clone();
381380
}
382381
if from_manifest.is_empty() {
383-
return Cow::Borrowed(from_config);
382+
return from_config.clone();
384383
}
385384

386385
// We could just chain from_manifest and from_config,
@@ -405,7 +404,7 @@ impl<'cfg> Workspace<'cfg> {
405404
combined.insert(url.clone(), cdeps.clone());
406405
}
407406
}
408-
Cow::Owned(combined)
407+
combined
409408
}
410409

411410
/// Returns an iterator over all packages in this workspace

0 commit comments

Comments
 (0)