From 09881b5025ef797821d9c6f238b332318795fd0c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 28 Mar 2025 07:07:56 -0700 Subject: compiler: reduce some equal-based sequence functions. * stdlib/compiler.tl (compiler comp-fun-form): Recognize two-argument forms of remove, count, pos, member and subst. When these don't specify test, key or map functions, they are equivalent to remqual, countqual, posqual, memqual and subqual. These functions are a bit faster because they have no arguments to default and some of their C implementations call the equal function either directly or via a pointer, rather than via going via funcall. The exceptions are posqual and subqual which actually call pos; but even for these it is still slightly advantageous to convert to to the fixed arity function, because funcall2 doesn't have to default the optional arguments with colon_k. --- stdlib/compiler.tl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index 1dbd2b73..836d53cd 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -1402,6 +1402,11 @@ ^(progn ,*args nil)))) ((@(or identity use + * min max logior logand) @a) (return-from comp-fun-form me.(compile oreg env a))) + ((remove @obj @seq) (set form (rlcp ^(remqual ,obj ,seq) form))) + ((count @obj @seq) (set form (rlcp ^(countqual ,obj ,seq) form))) + ((pos @obj @seq) (set form (rlcp ^(posqual ,obj ,seq) form))) + ((member @obj @seq) (set form (rlcp ^(memqual ,obj ,seq) form))) + ((subst @obj @seq) (set form (rlcp ^(subqual ,obj ,seq) form))) (@(require (chain . @nil) (> olev 5) (can-inline-chain form)) -- cgit v1.2.3