mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 12:38:43 +00:00
Optimize drivers::crates_io::Vfs
: Use BTreeMap
(#325) instead of HashMap
.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
16b16c482c
commit
7f9ad613a8
2 changed files with 4 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::HashMap, hash_set::HashSet},
|
collections::{hash_set::HashSet, BTreeMap},
|
||||||
io,
|
io,
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
@ -10,14 +10,10 @@ use normalize_path::NormalizePath;
|
||||||
/// This type stores the filesystem structure for the crate tarball
|
/// This type stores the filesystem structure for the crate tarball
|
||||||
/// extracted in memory and can be passed to
|
/// extracted in memory and can be passed to
|
||||||
/// `cargo_toml::Manifest::complete_from_abstract_filesystem`.
|
/// `cargo_toml::Manifest::complete_from_abstract_filesystem`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
pub(super) struct Vfs(HashMap<Box<Path>, HashSet<Box<str>>>);
|
pub(super) struct Vfs(BTreeMap<Box<Path>, HashSet<Box<str>>>);
|
||||||
|
|
||||||
impl Vfs {
|
impl Vfs {
|
||||||
pub(super) fn new() -> Self {
|
|
||||||
Self(HashMap::with_capacity(16))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// * `path` - must be canonical, must not be empty.
|
/// * `path` - must be canonical, must not be empty.
|
||||||
pub(super) fn add_path(&mut self, mut path: &Path) {
|
pub(super) fn add_path(&mut self, mut path: &Path) {
|
||||||
while let Some(parent) = path.parent() {
|
while let Some(parent) = path.parent() {
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl ManifestVisitor {
|
||||||
// Cargo.toml is quite large usually.
|
// Cargo.toml is quite large usually.
|
||||||
cargo_toml_content: Vec::with_capacity(2000),
|
cargo_toml_content: Vec::with_capacity(2000),
|
||||||
manifest_dir_path,
|
manifest_dir_path,
|
||||||
vfs: Vfs::new(),
|
vfs: Vfs::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue