]> Repositorios git - scryer-prolog.git/commitdiff
remove optional (+)/1 prefix in get_atts/2 and put_atts/2 calls
authorMarkus Triska <[email protected]>
Sun, 20 Aug 2023 19:38:33 +0000 (21:38 +0200)
committerMarkus Triska <[email protected]>
Tue, 22 Aug 2023 19:52:55 +0000 (21:52 +0200)
The (+)/1 prefix in get_atts/2 at line 4219 by itself already causes a
greater than 15% slowdown for the benchmark shown in #1730:

    ?- N #= 2^14,
       time(((between(1, N, _),
              X #\= Y,
              false)
            ; true)).

The performance impact is not a good reason to remove the optional
(+)/1 prefix! Performance issues should be addressed at the root, in
this case get_atts/2 (#1962). We should never manually work around
performance issues in built-in predicates.

In contrast, readability is a good argument, and I find the calls
slightly easier to read without the optional (+)/1 prefix.

The prefix is now consistently omitted when possible.

src/lib/clpz.pl

index a66556873ecb5ea3d4636ca52250f825c491444c..fbb78554bb0f2892e953150222342cd1dbd18c1a 100644 (file)
@@ -3967,7 +3967,7 @@ insert_queue(Element, Which) -->
               Tail0 = [Element|Tail]
           ;   Head = [Element|Tail]
           ),
-          put_atts(Arg, +queue(Head,Tail)) }.
+          put_atts(Arg, queue(Head,Tail)) }.
 
 
 domain_spread(Dom, Spread) :-
@@ -4199,9 +4199,9 @@ ignore(Goal) :- ( Goal -> true ; true ).
 
 print_queue -->
         state(queue(Goal,Fast,Slow,_)),
-        { ignore(get_atts(Goal, +queue(GHs,_))),
-          ignore(get_atts(Fast, +queue(FHs,_))),
-          ignore(get_atts(Slow, +queue(SHs,_))),
+        { ignore(get_atts(Goal, queue(GHs,_))),
+          ignore(get_atts(Fast, queue(FHs,_))),
+          ignore(get_atts(Slow, queue(SHs,_))),
           format("Current queue:~n   goal: ~q~n   fast: ~q~n   slow: ~q~n~n", [GHs,FHs,SHs]) }.
 
 
@@ -4216,14 +4216,14 @@ queue_get_arg(Which, Element) -->
 
 queue_get_arg_(Queue, Which, Element) :-
         arg(Which, Queue, Arg),
-        get_atts(Arg, +queue([Element|Elements],Tail)),
+        get_atts(Arg, queue([Element|Elements],Tail)),
         (   var(Elements) ->
             put_atts(Arg, -queue(_,_))
-        ;   put_atts(Arg, +queue(Elements,Tail))
+        ;   put_atts(Arg, queue(Elements,Tail))
         ).
 
 queue_enabled --> state(queue(_,_,_,Aux)), { \+ get_atts(Aux, disabled) }.
-disable_queue --> state(queue(_,_,_,Aux)), { put_atts(Aux, +disabled) }.
+disable_queue --> state(queue(_,_,_,Aux)), { put_atts(Aux, disabled) }.
 enable_queue --> state(queue(_,_,_,Aux)), { put_atts(Aux, -disabled) }.
 
 portray_propagator(propagator(P,_), F) :- functor(P, F, _).