(dired-repeat-over-lines
,arg
(lambda ()
- (if ,show-progress (sit-for 0))
+ ,@(when show-progress '((sit-for 0)))
(setq results (cons ,body results))))
(when (< ,arg 0)
(setq results (nreverse results)))
found (not (null next-position)))
(while next-position
(goto-char next-position)
- (if ,show-progress (sit-for 0))
+ ,@(when show-progress '((sit-for 0)))
(setq results (cons ,body results))
;; move after last match
(goto-char next-position)
(set-marker next-position nil)
(setq next-position (and (re-search-forward regexp nil t)
(point-marker)))))
- (if (and ,distinguish-one-marked (= (length results) 1))
- (setq results (cons t results)))
+ ,@(when distinguish-one-marked
+ '((if (= (length results) 1) (setq results (cons t results)))))
(if found
results
(unless (eq ,arg 'marked)
;; FIXME: We are conservative here: any variable changed in the
;; THEN branch will be barred from substitution in the ELSE
;; branch, despite the branches being mutually exclusive.
+ (cond
+ ((byte-compile-nilconstp test)
+ (byte-compile-warn-x then "Unreachable `then' clause"))
+ ((and else (byte-compile-trueconstp test))
+ (byte-compile-warn-x else "Unreachable `else' clause")))
(let* ((test-opt (byte-optimize-form test nil))
(const (macroexp-const-p test-opt))
;; Avoid traversing dead branches.
(let ((tail exps)
(args nil))
(while tail
+ (when (cdr tail)
+ (cond
+ ((and (eq fn 'and) (byte-compile-nilconstp (car tail)))
+ (byte-compile-warn-x (cdr tail) "Unreachable `and' clause"))
+ ((and (eq fn 'or) (byte-compile-trueconstp (car tail)))
+ (byte-compile-warn-x (cdr tail) "Unreachable `or' clause"))))
(push (byte-optimize-form
(car tail) (and for-effect (null (cdr tail))))
args)
(and (not for-effect) form))
(`(condition-case ,var ,exp . ,clauses)
- `(,fn ,var ;Not evaluated.
+ `(,fn ,var ;Not evaluated.
,(byte-optimize-form exp
(if (assq :success clauses)
(null var)
for-effect))
- ,@(mapcar (lambda (clause)
- (let ((byte-optimize--lexvars
- (and lexical-binding
- (if var
- (cons (list var t)
- byte-optimize--lexvars)
- byte-optimize--lexvars))))
- (cons (car clause)
- (byte-optimize-body (cdr clause) for-effect))))
- clauses)))
+ ,@(mapcar (lambda (clause)
+ (let ((byte-optimize--lexvars
+ (and lexical-binding
+ (if var
+ (cons (list var t)
+ byte-optimize--lexvars)
+ byte-optimize--lexvars))))
+ (cons (car clause)
+ (byte-optimize-body (cdr clause) for-effect))))
+ clauses)))
(`(unwind-protect ,protected-expr :fun-body ,unwind-fun)
;; FIXME: The return value of UNWIND-FUN is never used so we
(`(catch ,tag . ,exps)
`(,fn ,(byte-optimize-form tag nil)
- . ,(byte-optimize-body exps for-effect)))
+ . ,(byte-optimize-body exps for-effect)))
;; Needed as long as we run byte-optimize-form after cconv.
(`(internal-make-closure ,vars ,env . ,rest)
(let ((lexvar (assq var byte-optimize--lexvars))
(value (byte-optimize-form expr nil)))
(when lexvar
- (setcar (cdr lexvar) t) ; Mark variable to be kept.
- (setcdr (cdr lexvar) nil) ; Inhibit further substitution.
+ (setcar (cdr lexvar) t) ; Mark variable to be kept.
+ (setcdr (cdr lexvar) nil) ; Inhibit further substitution.
;; Cancel substitution of variables aliasing this one.
(let ((aliased-vars byte-optimize--aliased-vars))
(put 'char-before 'compiler-macro #'bytecomp--char-before)
(defun bytecomp--char-before (form &optional arg &rest junk-args)
(if junk-args
- form ; arity error
- `(char-after (1- (or ,arg (point))))))
+ form ; arity error
+ `(char-after (1- ,(cond
+ ((byte-compile-nilconstp arg) '(point))
+ ((byte-compile-trueconstp arg) arg)
+ (t `(or ,arg (point))))))))
(put 'backward-char 'compiler-macro #'bytecomp--backward-char)
(defun bytecomp--backward-char (form &optional arg &rest junk-args)
(if junk-args
- form ; arity error
- `(forward-char (- (or ,arg 1)))))
+ form ; arity error
+ `(forward-char ;; (- (or ,arg 1))
+ (- ,(cond
+ ((byte-compile-nilconstp arg) 1)
+ ((byte-compile-trueconstp arg) arg)
+ (t `(or ,arg 1)))))))
(put 'backward-word 'compiler-macro #'bytecomp--backward-word)
(defun bytecomp--backward-word (form &optional arg &rest junk-args)
(if junk-args
- form ; arity error
- `(forward-word (- (or ,arg 1)))))
+ form ; arity error
+ `(forward-word ;; (- (or ,arg 1))
+ (- ,(cond
+ ((byte-compile-nilconstp arg) 1)
+ ((byte-compile-trueconstp arg) arg)
+ (t `(or ,arg 1)))))))
(defun bytecomp--check-keyword-args (form arglist allowed-keys required-keys)
(let ((fun (car form)))