=== modified file 'lisp/emacs-lisp/byte-opt.el' --- lisp/emacs-lisp/byte-opt.el 2014-06-02 00:18:22 +0000 +++ lisp/emacs-lisp/byte-opt.el 2014-06-23 06:30:10 +0000 @@ -1057,11 +1057,27 @@ (if (nth 1 form) form)) +(defun byte-optimize-point-location (form) + ;; For OP in '=', 'eq' and 'equal': + ;; (OP (point) (point-min)) and (OP (point-min) (point)) => (bobp) + ;; (OP (point) (point-max)) and (OP (point-max) (point)) => (eobp) + (let ((op0 (nth 1 form)) (op1 (nth 2 form))) + (cond ((or (and (equal op0 '(point)) (equal op1 '(point-min))) + (and (equal op0 '(point-min)) (equal op1 '(point)))) + '(bobp)) + ((or (and (equal op0 '(point)) (equal op1 '(point-max))) + (and (equal op0 '(point-max)) (equal op1 '(point)))) + '(eobp)) + (t form)))) + (put 'and 'byte-optimizer 'byte-optimize-and) (put 'or 'byte-optimizer 'byte-optimize-or) (put 'cond 'byte-optimizer 'byte-optimize-cond) (put 'if 'byte-optimizer 'byte-optimize-if) (put 'while 'byte-optimizer 'byte-optimize-while) +(put '= 'byte-optimizer 'byte-optimize-point-location) +(put 'eq 'byte-optimizer 'byte-optimize-point-location) +(put 'equal 'byte-optimizer 'byte-optimize-point-location) ;; byte-compile-negation-optimizer lives in bytecomp.el (put '/= 'byte-optimizer 'byte-compile-negation-optimizer)