Function: byte-optimize-member

byte-optimize-member is a byte-compiled function defined in byte-opt.el.gz.

Signature

(byte-optimize-member FORM)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/byte-opt.el.gz
(defun byte-optimize-member (form)
  (cond
   ((/= (length (cdr form)) 2) form)    ; arity error
   ((null (nth 2 form))                 ; empty list
    `(progn ,(nth 1 form) nil))
   ;; Replace `member' or `memql' with `memq' if the first arg is a symbol
   ;; or fixnum, or the second arg is a list of symbols or fixnums.
   ((or (byte-optimize--constant-symbol-p (nth 1 form))
        (byte-optimize--fixnump (nth 1 form))
        (let ((arg2 (nth 2 form)))
          (and (macroexp-const-p arg2)
               (let ((listval (byteopt--eval-const arg2)))
                 (and (listp listval)
                      (not (memq nil (mapcar
                                      (lambda (o)
                                        (or (symbolp o)
                                            (byte-optimize--fixnump o)))
                                      listval))))))))
    (cons 'memq (cdr form)))
   (t form)))