From: David Kastrup <dak@gnu.org>
Cc: rms@gnu.org, emacs-devel@gnu.org
Subject: Re: [harder@ifa.au.dk: Speed of all-completions]
Date: 15 Jun 2004 15:27:53 +0200 [thread overview]
Message-ID: <x5smcxgdd2.fsf@lola.goethe.zz> (raw)
In-Reply-To: <jeu0xdrpc7.fsf@sykes.suse.de>
[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]
Andreas Schwab <schwab@suse.de> writes:
> David Kastrup <dak@gnu.org> writes:
>
> > Andreas Schwab <schwab@suse.de> writes:
> >
> >> David Kastrup <dak@gnu.org> writes:
> >>
> >> > Andreas Schwab <schwab@suse.de> writes:
> >> >
> >> >> This is due to this change:
> >> >>
> >> >> (Ftry_completion, Fall_completions, Ftest_completion): Bind
> >> >> case-fold-search to the value of completion-ignore-case when
> >> >> checking completion-regexp-list.
> >> >>
> >> >> I've checked in a fix that avoids the overhead of specbind when
> >> >> completion-regexp-list is empty.
> >> >
> >> > At the cost of being more expensive when it isn't.
> >>
> >> Why is it more expensive? The check for CONSP (completion-regexp-list)
> >> has to be done anyway, and can be CSE'd by the compiler.
> >
> > Because you are redoing the binding for every element in the loop,
> > while it is needed only once.
>
> I did not change anything in this regard.
Serves me right from just looking at the result instead of what you
started with.
To illustrate what I mean, here is a patch against the most recent
version. Note that I have to undo the binding before calling a
user-defined predicate function (which might rely on the original
binding). The last of your three changes, not running in a loop, was
not improvable, however.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3633 bytes --]
--- minibuf.c 15 Jun 2004 00:47:07 +0200 1.269
+++ minibuf.c 15 Jun 2004 15:22:48 +0200
@@ -1207,6 +1207,7 @@
|| NILP (XCAR (alist))));
int index = 0, obsize = 0;
int matchcount = 0;
+ int bind_count = -1;
Lisp_Object bucket, zero, end, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -1285,21 +1286,22 @@
XSETFASTINT (zero, 0);
/* Ignore this element if it fails to match all the regexps. */
- if (CONSP (Vcompletion_regexp_list))
- {
- int count = SPECPDL_INDEX ();
- specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
- for (regexps = Vcompletion_regexp_list; CONSP (regexps);
- regexps = XCDR (regexps))
- {
- tem = Fstring_match (XCAR (regexps), eltstring, zero);
- if (NILP (tem))
- break;
+ {
+ for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+ regexps = XCDR (regexps))
+ {
+ if (bind_count < 0) {
+ bind_count = SPECPDL_INDEX ();
+ specbind (Qcase_fold_search,
+ completion_ignore_case ? Qt : Qnil);
}
- unbind_to (count, Qnil);
- if (CONSP (regexps))
- continue;
- }
+ tem = Fstring_match (XCAR (regexps), eltstring, zero);
+ if (NILP (tem))
+ break;
+ }
+ if (CONSP (regexps))
+ continue;
+ }
/* Ignore this element if there is a predicate
and the predicate doesn't like it. */
@@ -1310,6 +1312,10 @@
tem = Fcommandp (elt, Qnil);
else
{
+ if (bind_count >= 0) {
+ unbind_to (bind_count, Qnil);
+ bind_count = -1;
+ }
GCPRO4 (tail, string, eltstring, bestmatch);
tem = type == 3
? call2 (predicate, elt,
@@ -1391,6 +1397,11 @@
}
}
+ if (bind_count >= 0) {
+ unbind_to (bind_count, Qnil);
+ bind_count = -1;
+ }
+
if (NILP (bestmatch))
return Qnil; /* No completions found */
/* If we are ignoring case, and there is no exact match,
@@ -1453,6 +1464,7 @@
&& (!SYMBOLP (XCAR (alist))
|| NILP (XCAR (alist))));
int index = 0, obsize = 0;
+ int bind_count = -1;
Lisp_Object bucket, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -1537,21 +1549,22 @@
XSETFASTINT (zero, 0);
/* Ignore this element if it fails to match all the regexps. */
- if (CONSP (Vcompletion_regexp_list))
- {
- int count = SPECPDL_INDEX ();
- specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
- for (regexps = Vcompletion_regexp_list; CONSP (regexps);
- regexps = XCDR (regexps))
- {
- tem = Fstring_match (XCAR (regexps), eltstring, zero);
- if (NILP (tem))
- break;
+ {
+ for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+ regexps = XCDR (regexps))
+ {
+ if (bind_count < 0) {
+ bind_count = SPECPDL_INDEX ();
+ specbind (Qcase_fold_search,
+ completion_ignore_case ? Qt : Qnil);
}
- unbind_to (count, Qnil);
- if (CONSP (regexps))
- continue;
- }
+ tem = Fstring_match (XCAR (regexps), eltstring, zero);
+ if (NILP (tem))
+ break;
+ }
+ if (CONSP (regexps))
+ continue;
+ }
/* Ignore this element if there is a predicate
and the predicate doesn't like it. */
@@ -1562,6 +1575,10 @@
tem = Fcommandp (elt, Qnil);
else
{
+ if (bind_count >= 0) {
+ unbind_to (bind_count, Qnil);
+ bind_count = -1;
+ }
GCPRO4 (tail, eltstring, allmatches, string);
tem = type == 3
? call2 (predicate, elt,
@@ -1576,6 +1593,11 @@
}
}
+ if (bind_count >= 0) {
+ unbind_to (bind_count, Qnil);
+ bind_count = -1;
+ }
+
return Fnreverse (allmatches);
}
\f
[-- Attachment #3: Type: text/plain, Size: 80 bytes --]
Does this look sane enough?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2004-06-15 13:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-13 21:48 [harder@ifa.au.dk: Speed of all-completions] Richard Stallman
2004-06-13 22:22 ` Andreas Schwab
2004-06-14 23:27 ` David Kastrup
2004-06-15 0:04 ` Luc Teirlinck
2004-06-15 7:29 ` David Kastrup
2004-06-15 11:00 ` Andreas Schwab
2004-06-15 11:28 ` David Kastrup
2004-06-15 12:13 ` Andreas Schwab
2004-06-15 13:27 ` David Kastrup [this message]
2004-06-15 13:40 ` Andreas Schwab
2004-06-15 13:48 ` David Kastrup
2004-06-15 14:08 ` Andreas Schwab
2004-06-15 14:19 ` David Kastrup
2004-06-15 14:32 ` Andreas Schwab
2004-06-15 15:42 ` Luc Teirlinck
2004-06-15 15:55 ` David Kastrup
2004-06-18 18:45 ` Luc Teirlinck
2004-06-19 3:19 ` Richard Stallman
2004-06-20 22:35 ` David Kastrup
2004-06-15 18:13 ` Richard Stallman
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=x5smcxgdd2.fsf@lola.goethe.zz \
--to=dak@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/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.