]> Repositorios git - scryer-prolog.git/commitdiff
remove two unecessary clones
authorSkgland <[email protected]>
Tue, 18 Nov 2025 20:27:23 +0000 (21:27 +0100)
committerBennet Bleßmann <[email protected]>
Tue, 18 Nov 2025 20:29:22 +0000 (21:29 +0100)
src/machine/lib_machine/mod.rs

index fc0369403de983224d6fa133877e45fb76591419..653fc2a4dc6927afb9dd3dab6f03f5c6594e907d 100644 (file)
@@ -128,9 +128,11 @@ impl Term {
     pub fn try_conjunction(value: impl IntoIterator<Item = Term>) -> Option<Self> {
         let mut iter = value.into_iter();
         iter.next().map(|first| {
-            Term::try_conjunction(iter)
-                .map(|rest| Term::compound(",", [first.clone(), rest]))
-                .unwrap_or(first)
+            if let Some(rest) = Term::try_conjunction(iter) {
+                Term::compound(",", [first, rest])
+            } else {
+                first
+            }
         })
     }
 
@@ -143,9 +145,11 @@ impl Term {
     pub fn try_disjunction(value: impl IntoIterator<Item = Term>) -> Option<Self> {
         let mut iter = value.into_iter();
         iter.next().map(|first| {
-            Term::try_disjunction(iter)
-                .map(|rest| Term::compound(";", [first.clone(), rest]))
-                .unwrap_or(first)
+            if let Some(rest) = Term::try_disjunction(iter) {
+                Term::compound(";", [first, rest])
+            } else {
+                first
+            }
         })
     }
 }