Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
fetch: move `Component::from` outside of loop
Merged fintohaps opened 2 months ago

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.

1 file changed +2 -2 0e9d7607 4286590f
modified crates/radicle-fetch/src/git/mem.rs
@@ -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))
        })
    }