From: npostavs@users.sourceforge.net
To: Sho Takemori <stakemorii@gmail.com>
Cc: 26079@debbugs.gnu.org, Michal Nazarewicz <mina86@mina86.com>
Subject: bug#26079: 26.0.50; Performance regression in delete-trailing-whitespace
Date: Mon, 13 Mar 2017 22:01:06 -0400 [thread overview]
Message-ID: <87d1dk7h25.fsf@users.sourceforge.net> (raw)
In-Reply-To: <CAHbQ=cVMOMhjCW88CjpOg0==s18qe13r5FdKGOeB1WP0+Br0QA@mail.gmail.com> (Sho Takemori's message of "Mon, 13 Mar 2017 11:13:28 +0900")
tags 26079 confirmed
quit
Sho Takemori <stakemorii@gmail.com> writes:
> Dear developers,
>
> delete-trailing-whitespace in Emacs 26 for large files is very slow.
>
> For example, it took about 1.6s for this file (https://raw.githubusercontent.com/stakemori/e8theta_degree3/master/results/wt18_17_5/wt18_17_5.org).
> But in Emacs 25, it took about 0.003s.
> A similar code to the following is used in delete-trailing-whitespace. And it is slow for large files.
>
> (save-excursion
> (let ((end-marker nil))
> (goto-char (point-min))
> (with-syntax-table (make-syntax-table (syntax-table))
> (modify-syntax-entry ?\f "_")
> (modify-syntax-entry ?\n "_")
> (re-search-forward "\\s-+$" end-marker t))))
It seems that this regex causes a lot of backtracking when \n is not
whitespace. It was introduced in [1: 7c6317a049]; restoring the
strategy from before seems make it fast again. Michal, do you think
that's the best way to fix this?
--- i/lisp/simple.el
+++ i/lisp/simple.el
@@ -632,12 +632,11 @@ delete-trailing-whitespace
(goto-char (or start (point-min)))
(with-syntax-table (make-syntax-table (syntax-table))
;; Don't delete formfeeds, even if they are considered whitespace.
(modify-syntax-entry ?\f "_")
- ;; Treating \n as non-whitespace makes things easier.
- (modify-syntax-entry ?\n "_")
- (while (re-search-forward "\\s-+$" end-marker t)
- (let ((b (match-beginning 0)) (e (match-end 0)))
+ (while (re-search-forward "\\s-$" end-marker t)
+ (skip-syntax-backward "-" (line-beginning-position))
+ (let ((b (point)) (e (match-end 0)))
(when (region-modifiable-p b e)
(delete-region b e)))))
(if end
(set-marker end-marker nil)
1: 2016-07-04 23:44:06 +0200 7c6317a0498b6690ea668909ac012cb45e6f809b
Simplify ‘delete-trailing-whitespace’ by not treating \n as whitespace
next prev parent reply other threads:[~2017-03-14 2:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-13 2:13 bug#26079: 26.0.50; Performance regression in delete-trailing-whitespace Sho Takemori
2017-03-14 2:01 ` npostavs [this message]
2017-03-14 13:00 ` Michal Nazarewicz
2017-03-15 2:36 ` npostavs
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d1dk7h25.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=26079@debbugs.gnu.org \
--cc=mina86@mina86.com \
--cc=stakemorii@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.