Commit cfcf9bca authored by Sven-Hendrik Haase's avatar Sven-Hendrik Haase
Browse files

Merge branch 'reverse_deps_hashset' into 'master'

Use a Hashset to not append duplicates

Closes #2

See merge request archlinux/rebuilder!3
parents e1562ea3 794749df
Pipeline #3037 passed with stages
in 1 minute and 36 seconds
......@@ -28,8 +28,8 @@ fn find_package_anywhere<'a>(
/// Retrieve a HashMap of all reverse dependencies.
fn get_reverse_deps_map(
pacman: &alpm::Alpm,
) -> Result<HashMap<String, Vec<String>>, Box<dyn Error>> {
let mut reverse_deps: HashMap<String, Vec<String>> = HashMap::new();
) -> Result<HashMap<String, HashSet<String>>, Box<dyn Error>> {
let mut reverse_deps: HashMap<String, HashSet<String>> = HashMap::new();
let dbs = pacman.syncdbs();
for db in dbs {
......@@ -40,15 +40,27 @@ fn get_reverse_deps_map(
for dep in pkg.depends() {
reverse_deps
.entry(dep.name().to_string())
.and_modify(|e| e.push(pkg.name().to_string()))
.or_insert_with(|| vec![pkg.name().to_string()]);
.and_modify(|e| {
e.insert(pkg.name().to_string());
})
.or_insert_with(|| {
let mut modify = HashSet::new();
modify.insert(pkg.name().to_string());
modify
});
}
for dep in pkg.makedepends() {
reverse_deps
.entry(dep.name().to_string())
.and_modify(|e| e.push(pkg.name().to_string()))
.or_insert_with(|| vec![pkg.name().to_string()]);
.and_modify(|e| {
e.insert(pkg.name().to_string());
})
.or_insert_with(|| {
let mut modify = HashSet::new();
modify.insert(pkg.name().to_string());
modify
});
}
}
}
......
Supports Markdown
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