From: Mark Thom Date: Mon, 18 Apr 2022 02:10:13 +0000 (-0600) Subject: very minor optimizations X-Git-Tag: v0.9.1~50 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=9d5264c5a3bce86de91acc5bbb75e0011fe162d7;p=scryer-prolog.git very minor optimizations --- diff --git a/Cargo.toml b/Cargo.toml index 7ed79773..89241b95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,4 +79,4 @@ modular-bitfield = { git = "https://github.com/mthom/modular-bitfield" } num-rug-adapter = { git = "https://github.com/mthom/num-rug-adapter" } [profile.release] -debug = true +debug = true \ No newline at end of file diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index b839ee5d..786c56f2 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -587,8 +587,6 @@ read(Term) :- current_input(Stream), read(Stream, Term). -% term_variables. - % ensures List is either a variable or a list. can_be_list(List, _) :- var(List), @@ -603,6 +601,8 @@ can_be_list(List, _) :- can_be_list(List, PI) :- throw(error(type_error(list, List), PI)). +% term_variables. + term_variables(Term, Vars) :- can_be_list(Vars, term_variables/2), '$term_variables'(Term, Vars). @@ -1375,13 +1375,14 @@ must_be_number(N, PI) :- ; throw(error(instantiation_error, PI)) ). -can_be_chars_or_vars(Cs, _) :- var(Cs), !. +can_be_chars_or_vars(Cs, _) :- var(Cs), !. can_be_chars_or_vars(Cs, PI) :- chars_or_vars(Cs, PI). chars_or_vars([], _). chars_or_vars([C|Cs], PI) :- ( nonvar(C) -> - ( catch(builtins:atom_length(C, 1), _, false) -> + ( atom(C), + atom_length(C, 1) -> ( nonvar(Cs) -> chars_or_vars(Cs, PI) ; false diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 3d27e93a..fcbeb553 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -707,7 +707,7 @@ impl MachineState { indices: &IndexStore, stub_gen: impl Fn() -> FunctorStub, ) -> CallResult { - let nx = self.registers[2]; + let nx = self.store(self.deref(self.registers[2])); if let Some(c) = string.chars().last() { if layout_char!(c) {