unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: 22586@debbugs.gnu.org
Subject: bug#22586: [PATCH 1/2] Optimise ‘point in message header’ check
Date: Sun,  7 Feb 2016 18:40:46 +0100	[thread overview]
Message-ID: <1454866846-27319-1-git-send-email-mina86@mina86.com> (raw)

* 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 77e471f..88f198f 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3516,12 +3516,12 @@ message-fill-paragraph
 (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.7.0.rc3.207.g0ac5344






             reply	other threads:[~2016-02-07 17:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07 17:40 Michal Nazarewicz [this message]
2016-02-07 17:42 ` bug#22586: [PATCH 2/2] Make `message-beginning-of-line' aware of folded headers Michal Nazarewicz
2016-02-09  3:07 ` bug#22586: [PATCH 1/2] Optimise ‘point in message header’ check Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454866846-27319-1-git-send-email-mina86@mina86.com \
    --to=mina86@mina86.com \
    --cc=22586@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).