Subject: bug#36139: [PATCH] Make better use of the switch op in cond forms

From: Mattias Engdegård <[email-masked]>
Date: Wed, 19 Jun 2019 16:03:43 +0200

18 juni 2019 kl. 21.03 skrev Stefan Monnier <[email-masked]>:
> 
> LGTM.  The other direction is to just always use `member`
> and speed up the implementation of `member` by testing the type of
> the first arg and dispatch to memq/memql when possible.

Here is a patch that does some cheap static optimisations: equal/eql and member/memql become eq and memq if constant symbols are involved. (Works for me, bootstraps fine, etc.)

I considered doing the same for equal->eql and member->memql. It turns out that equal is faster than eql for numbers, since eql doesn't have its own byte op. For the same reason, member is faster than memql for lists of up to 5 elements (on this machine). While we could reduce equal to eql for constant lists > 5 elements of only symbols and numbers, it's perhaps more trouble than it's worth.