[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improving regexp-opt
From: |
Stefan Monnier |
Subject: |
Re: Improving regexp-opt |
Date: |
Wed, 17 Apr 2019 23:49:48 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>> Furthermore, even when the result is noticeably shorter, have you
>> compared the performance of the regexp-matcher? I expect that you won't
>> be able to see a measurable difference there.
>
> For the very particular regexp for cXr, cXXr and cXXXr, the shorter
> "\\(?:c[ad]\\(?:[ad][ad]?\\)?r\\)" takes 40% of the time compared to the
> longer
Indeed, this is a case where the result is really better. It's probably
a case where we shouldn't have started with the list of cXXr but should
have gone straight to generate "c[ad]\\(?:[ad][ad]?\\)?r" or
"c[ad]\\{1,3\\}r" without going through regexp-opt, but there could be
cases where we'd end up going through regexp-opt.
>> As I said, if you really want to improve on regexp-opt, you have to go
>> through a *real* DFA and that means not returning a regexp but a DFA, so
>> it's a completely different beast from `regexp-opt`.
>
> I don't understand what you mean by real DFA in emacs and how to
> implement that.
Emacs doesn't have any particular support for DFAs, currently, so you'd
have to code it up (that's what I did in lex.el, for example).
Stefan