diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-03-28 07:07:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-03-28 07:07:56 -0700 |
commit | 09881b5025ef797821d9c6f238b332318795fd0c (patch) | |
tree | 9a33d893e979ff76e09cf3d648932c57228df714 /stdlib/compiler.tl | |
parent | 48a7a911475fbeccc2e1fe078a5db1544909096b (diff) | |
download | txr-09881b5025ef797821d9c6f238b332318795fd0c.tar.gz txr-09881b5025ef797821d9c6f238b332318795fd0c.tar.bz2 txr-09881b5025ef797821d9c6f238b332318795fd0c.zip |
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.
Diffstat (limited to 'stdlib/compiler.tl')
-rw-r--r-- | stdlib/compiler.tl | 5 |
1 files changed, 5 insertions, 0 deletions
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)) |