Re: address@hidden: Speed of all-completions]

David Kastrup wrote:
> Is one single prolonged binding using specbind expensive or was the
> efficiency problem completely caused by the fact that it was used
> countless times in a loop?
The single prolonged binding is expensive, as in most cases the loop
is not entered even once.
At least that's what I understood.
Does not look like it. I could provide a patch and timings showing
that with one single binding around essentially the entire functions
and _without_ the `if (CONSP (Vcompletion_regexp_list))', there is a
10-fold improvement (in Jesper's example), if completion-regexp-list
is non-nil and a negligible deterioration if it is nil (everything
compared with the current CVS code).
However, before going into that, something else needs to be looked at.
Binding (essentially) around the entire functions means that the
binding is also in effect around the call to PREDICATE. Actually, if
PREDICATE uses case-fold-search, the binding either _should_ be in
effect, or PREDICATE should explicitly bind case-fold-search itself.
The _one single_ problem with the one prolonged binding might occur if
PREDICATE asks questions to the user in the minibuffer. We have
forgotten the user defined value and it can not be restored. But it
should be restored, because otherwise the user might be confused.
It probably is possible to use all-completions and friends in an
unusual way (that is, for purposes other than minibuffer completion),
where PREDICATE _could_ ask minibuffer questions. _If so_, then we
either have to stick with the present version or apply your patch.
Sincerely,
Luc.