[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rx.el sexp regexp syntax
From: |
Tom Tromey |
Subject: |
Re: rx.el sexp regexp syntax |
Date: |
Sun, 27 May 2018 10:56:36 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
>>>>> "Alan" == Alan Mackenzie <address@hidden> writes:
>> Building the automaton is costly. In C, we build it once and save the
>> result in a variable so that every regexp match does not rebuild the
>> automaton each time.
Alan> Emacs has a (moderately large) cache of regexps, so that building the
Alan> automatons is done very rarely. Possibly just once each for each
Alan> session of Emacs.
I wonder about both of these statements.
On the one hand, AFAICT the regex cache is 20 items. From search.c:
#define REGEXP_CACHE_SIZE 20
That seems pretty small to me, given how prevalent regexps are in elisp.
On the other hand, in the past when I have tried to profile Emacs, I
haven't seen regexp compilation show up too much. IIRC I did see regexp
matching and the GC. Maybe this just points out the efficacy of the
cache -- maybe 20 items is plenty.
Perhaps the regexp matcher could use some micro-optimizations, like the
token-threading the bytecode interpreter does.
Alan> Are you suggesting here building an interpreter in Lisp directly to
Alan> execute rx expressions?
It's interesting, IMO, to consider compiling rx (or regexps generally)
to lisp bytecode. Perhaps with the JIT, it would boost performance in
some cases. (It may be slower, but it's worthwhile to do the
experiment.)
For other work in this area see Stefan's lex-parse-re package. I think
it includes a regexp matcher in elisp.
Tom
- Re: rx.el sexp regexp syntax, (continued)
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/27
- Re: rx.el sexp regexp syntax, Pierre Neidhardt, 2018/05/28
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/28
- Re: rx.el sexp regexp syntax, Richard Stallman, 2018/05/28
- Re: rx.el sexp regexp syntax, Robert Pluim, 2018/05/29
- Re: rx.el sexp regexp syntax, Philipp Stephani, 2018/05/29
- Re: rx.el sexp regexp syntax (WAS: Off Topic), Alan Mackenzie, 2018/05/25
- Re: rx.el sexp regexp syntax, Michael Heerdegen, 2018/05/25
- Re: rx.el sexp regexp syntax, Peter Neidhardt, 2018/05/25
- Re: rx.el sexp regexp syntax (WAS: Off Topic), Peter Neidhardt, 2018/05/25
- Re: rx.el sexp regexp syntax,
Tom Tromey <=
- Re: rx.el sexp regexp syntax, Alan Mackenzie, 2018/05/27
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/27
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/27
- Re: rx.el sexp regexp syntax, Pierre Neidhardt, 2018/05/28
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/28