From: Richard M. Stallman Date: Sun, 16 Oct 1994 08:20:07 +0000 (+0000) Subject: (count-lines): Do save-match-data only when necessary. X-Git-Tag: emacs-19.34~6300 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e406700d6968d41fe8292201d97611d35f48beca;p=emacs.git (count-lines): Do save-match-data only when necessary. --- diff --git a/lisp/simple.el b/lisp/simple.el index b4edb5c7ed3..090542e3cac 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -324,12 +324,12 @@ that uses or sets the mark." This is usually the number of newlines between them, but can be one more if START is not equal to END and the greater of them is not at the start of a line." - (save-match-data - (save-excursion - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (if (eq selective-display t) + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (if (eq selective-display t) + (save-match-data (let ((done 0)) (while (re-search-forward "[\n\C-m]" nil t 40) (setq done (+ 40 done))) @@ -339,8 +339,8 @@ and the greater of them is not at the start of a line." (if (and (/= start end) (not (bolp))) (1+ done) - done)) - (- (buffer-size) (forward-line (buffer-size)))))))) + done))) + (- (buffer-size) (forward-line (buffer-size))))))) (defun what-cursor-position () "Print info on cursor position (on screen and within buffer)."