[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improving regexp-opt
From: |
Miguel V. S. Frasson |
Subject: |
Re: Improving regexp-opt |
Date: |
Wed, 17 Apr 2019 21:59:38 -0300 |
> 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
"\\(?:c\\(?:\\(?:a\\(?:a[ad]\\|d[ad]\\|[ad]\\)\\|d\\(?:a[ad]\\|d[ad]\\|[ad]\\)\\|[ad]\\)r\\)\\)"
But most of the time the match time is equivalent, and although I made an
improvement in the computation of regexp-opt with FA, it still has complexity
of greater order.
For the example for
'("cond" "if" "when" "unless" "while"
"let" "let*" "progn" "prog1" "prog2"
"save-restriction" "save-excursion" "save-window-excursion"
"save-current-buffer" "save-match-data"
"catch" "throw" "unwind-protect" "condition-case")
now it takes "just" 50 times of the computation time of current regexp-opt
(instead of 70 times that it took before).
So I admit that it has little benefit.
> IOW it's just not a good deal.
I agree.
> 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.
best regards.
Miguel.
--
Miguel Vinicius Santini Frasson
address@hidden