Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to fxhashmap for speed #409

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tempfile = "3.6"
toml = "0.8.6"
clap = { version = "4.1.4", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] }
rustc-hash = "2.0"

[features]
debug = []
Expand Down
15 changes: 8 additions & 7 deletions src/cargo_ops/elaborate_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use cargo::{
ops::{self, Packages},
util::{context::GlobalContext, interning::InternedString, CargoResult},
};
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use tabwriter::TabWriter;

Expand All @@ -31,10 +32,10 @@ use super::{pkg_status::*, Options};
/// the update status of packages
pub struct ElaborateWorkspace<'ela> {
pub workspace: &'ela Workspace<'ela>,
pub pkgs: HashMap<PackageId, Package>,
pub pkg_deps: HashMap<PackageId, HashMap<PackageId, Dependency>>,
pub pkgs: FxHashMap<PackageId, Package>,
pub pkg_deps: FxHashMap<PackageId, FxHashMap<PackageId, Dependency>>,
/// Map of package status
pub pkg_status: RefCell<HashMap<Vec<PackageId>, PkgStatus>>,
pub pkg_status: RefCell<FxHashMap<Vec<PackageId>, PkgStatus>>,
/// Whether using workspace mode
pub workspace_mode: bool,
}
Expand Down Expand Up @@ -103,13 +104,13 @@ impl<'ela> ElaborateWorkspace<'ela> {
let resolve = ws_resolve
.workspace_resolve
.expect("Error getting workspace resolved");
let mut pkgs = HashMap::new();
let mut pkg_deps = HashMap::new();
let mut pkgs = FxHashMap::default();
let mut pkg_deps = FxHashMap::default();
for pkg in packages.get_many(packages.package_ids())? {
let pkg_id = pkg.package_id();
pkgs.insert(pkg_id, pkg.clone());
let deps = pkg.dependencies();
let mut dep_map = HashMap::new();
let mut dep_map = FxHashMap::default();
for dep_id in resolve.deps(pkg_id) {
for d in deps {
if d.matches_id(dep_id.0) {
Expand All @@ -125,7 +126,7 @@ impl<'ela> ElaborateWorkspace<'ela> {
workspace,
pkgs,
pkg_deps,
pkg_status: RefCell::new(HashMap::new()),
pkg_status: RefCell::new(FxHashMap::default()),
workspace_mode: options.workspace || workspace.current().is_err(),
})
}
Expand Down
Loading