From: "Mattias Engdegård" <mattiase@acm.org>
To: 30568@debbugs.gnu.org
Cc: Philipp <p.stephani2@gmail.com>
Subject: bug#30568: 27.0.50; `rx' doesn't create optimal regex for (group (or ...))
Date: Fri, 13 Dec 2019 20:18:58 +0100 [thread overview]
Message-ID: <7A6967D6-3859-4703-9223-E3CDFD8C2AA4@acm.org> (raw)
In-Reply-To: <wvr4r2petnvn.fsf@a.muc.corp.google.com>
> (rx (group (or "aaa" "bbb")))
> ==> \(\(?:aaa\|bbb\)\)
>
> This should generate \(aaa\|bbb\) instead. Of course, these regexes are
> equivalent, but the second one is easier to read (and maybe faster).
This remains unchanged, I'm afraid, despite rx being completely rewritten. Not that it matters much: brackets do not generate any regexp bytecode, thus matching performance isn't affected once the regexp has been compiled. When the brackets are required, there is no waste:
(rx (+ (or "aaa" "bbb")))
=> "\\(?:aaa\\|bbb\\)+"
Still, it's a bit untidy, and I like that you reported it. We could add a special value for the PAREN argument to regexp-opt to prevent bracketing altogether, I suppose. It isn't immediately on my to-do list, however.
prev parent reply other threads:[~2019-12-13 19:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 14:31 bug#30568: 27.0.50; `rx' doesn't create optimal regex for (group (or ...)) p.stephani2
2019-12-13 19:18 ` Mattias Engdegård [this message]
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=7A6967D6-3859-4703-9223-E3CDFD8C2AA4@acm.org \
--to=mattiase@acm.org \
--cc=30568@debbugs.gnu.org \
--cc=p.stephani2@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.