]> Repositorios git - scryer-prolog.git/commitdiff
compare characters directly in term comparison tests
authorMark Thom <[email protected]>
Thu, 5 Mar 2020 19:50:11 +0000 (12:50 -0700)
committerMark Thom <[email protected]>
Thu, 5 Mar 2020 19:50:11 +0000 (12:50 -0700)
src/prolog/machine/machine_state_impl.rs

index 9ac09ca93ca0f56223fbac734f42ea7078ec24e5..10468a368967c8b5b3cb651500ea6962631f9b7c 100644 (file)
@@ -2300,6 +2300,14 @@ impl MachineState {
                         return Ordering::Greater;
                     }
                 }
+                (
+                    HeapCellValue::Addr(Addr::Con(Constant::Char(c1))),
+                    HeapCellValue::Addr(Addr::Con(Constant::Char(c2))),
+                ) => {
+                    if c1 != c2 {
+                        return c1.cmp(&c2);
+                    }
+                }
                 (
                     HeapCellValue::Addr(Addr::Con(Constant::Atom(atom, _))),
                     HeapCellValue::Addr(Addr::Con(Constant::Char(c))),
@@ -2366,7 +2374,9 @@ impl MachineState {
                     HeapCellValue::Addr(Addr::AttrVar(hc1)),
                     HeapCellValue::Addr(Addr::PStrTail(hc2, _)),
                 ) => {
-                    return hc1.cmp(&hc2);
+                    if hc1 != hc2 {
+                        return hc1.cmp(&hc2);
+                    }
                 }
                 (HeapCellValue::Addr(Addr::HeapCell(_)), _)
               | (HeapCellValue::Addr(Addr::AttrVar(_)), _)