Commit 51a86b6a authored by Mattias Engdegård's avatar Mattias Engdegård
Browse files

Count (not X) as a switch condition

* lisp/emacs-lisp/bytecomp.el (byte-compile--cond-switch-prefix):
Treat (not VAR) and (null VAR) as (eq VAR nil) when computing the
extent of switch ops.
parent 0c58796a
......@@ -4340,6 +4340,16 @@ Return (TAIL VAR TEST CASES), where:
(push value keys)
(push (cons (list value) (or body '(t))) cases))
;; Treat (not X) as (eq X nil).
(`((,(or 'not 'null) ,(and var (pred symbolp))) . ,body)
(and (or (eq var switch-var) (not switch-var))
(setq switch-var var)
(setq switch-test 'eq)
(unless (memq nil keys)
(push nil keys)
(push (cons (list nil) (or body '(t))) cases))
(`((,(and fn (or 'memq 'memql 'member)) ,var ,expr) . ,body)
(and (symbolp var)
(or (eq var switch-var) (not switch-var))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment