fetch: move `Component::from` outside of loop

The previous code would convert the `remote` into a `Component` on
each iteration of the loop.

The conversion now happens outside of the loop and can be reused.
This commit is contained in:
Fintan Halpenny 2026-02-17 11:15:37 +00:00 committed by Lorenz Leutgeb
parent 0e9d7607e4
commit 4286590fd9
1 changed files with 2 additions and 2 deletions

View File

@ -26,10 +26,10 @@ impl Refdb {
&'a self,
remote: &'a PublicKey,
) -> impl Iterator<Item = (RefString, Oid)> + 'a {
let remote = Component::from(remote);
self.0.iter().filter_map(move |(refname, oid)| {
let ns = refname.to_namespaced()?;
(ns.namespace() == Component::from(remote))
.then(|| (ns.strip_namespace().to_ref_string(), *oid))
(ns.namespace() == remote).then(|| (ns.strip_namespace().to_ref_string(), *oid))
})
}