From 824a87f41f53eea3aa8ffcb9f065ce149213ebfb Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Tue, 9 Feb 2016 14:05:34 +1100 Subject: [PATCH] =?utf8?q?Optimise=20=E2=80=98point=20in=20message=20heade?= =?utf8?q?r=E2=80=99=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/gnus/message.el (message-point-in-header-p): Replace two unbound regular expression matches with a single bound string match thus reducing amount of work the function is doing. --- lisp/gnus/message.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 8a7ed4fffbe..9460710a477 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3524,12 +3524,12 @@ Message buffers and is not meant to be called directly." (defun message-point-in-header-p () "Return t if point is in the header." (save-excursion - (and - (not - (re-search-backward - (concat "^" (regexp-quote mail-header-separator) "\n") nil t)) - (re-search-forward - (concat "^" (regexp-quote mail-header-separator) "\n") nil t)))) + (save-restriction + (widen) + (let ((bound (+ (point-at-eol) 1)) case-fold-search) + (goto-char (point-min)) + (not (search-forward (concat "\n" mail-header-separator "\n") + bound t)))))) (defun message-do-auto-fill () "Like `do-auto-fill', but don't fill in message header." -- 2.39.2