unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Leo <sdl.web@gmail.com>, 12796@debbugs.gnu.org, Kim Storm <storm@cua.dk>
Subject: bug#12796: Optimize `ido-completing-read' for larger lists with flex matching enabled
Date: Thu, 08 Nov 2012 08:29:19 +0400	[thread overview]
Message-ID: <509B351F.8040607@yandex.ru> (raw)
In-Reply-To: <jwvliec97pr.fsf-monnier+emacs@gnu.org>

On 08.11.2012 6:05, Stefan Monnier wrote:
>> -      (setq re (mapconcat #'regexp-quote (split-string ido-text "") ".*"))
>> +      (setq re (mapconcat #'regexp-quote (split-string ido-text "" t)
>> ".*"))
>
> Sounds like a good change.  Tho:
>
>     (mapconcat (lambda (c) (regexp-quote (string c))) ido-text ".*")
>
> would work as well.

Indeed. A two-character change offering massive speedup looks cuter, 
though. And easier to understand for casual readers.

> You could try to speed up the regexp matching some more by eliminating
> backtracking (which should mostly eliminate a few pathological cases):
>
>     (let ((first t))
>       (mapconcat (lambda (c)
>                    (if first
>                        (progn (setq first nil) (regexp-quote (string c)))
>                      (concat "[^" (string c) "]*"
>                              (regexp-quote (string c)))))
>                  ido-text ""))

Yep, this adds some further speedup especially with longer string.
To use the existing testing setup (numbers are a bit different in this 
session):

;; omt 18000 15 abcdefghzzzzz 0.042
;; nbt 18000 15 abcdefghzzzzz 0.040

;; omt 18000 45 abcdefghzzz123 0.127
;; nbt 18000 45 abcdefghzzz123 0.087

>> I'm still going to see if I can make while-no-input work here, though.
>
> Yes, that'd be very welcome.

I sent a patch that doesn't seem to break anything for me:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12796#41

But in the light of the above numbers, it seems that (while-no-input) 
would almost always guard a section of code that takes 1/20th of a 
second to run, or less. Only useful when a user has floored "backspace", 
I think.





      reply	other threads:[~2012-11-08  4:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-04  5:58 bug#12796: Optimize `ido-completing-read' for larger lists with flex matching enabled Dmitry Gutov
2012-11-04  8:32 ` Leo
2012-11-04 13:53 ` Stefan Monnier
2012-11-04 17:05   ` Dmitry Gutov
2012-11-05  5:37     ` Dmitry Gutov
2012-11-06  1:45       ` Stefan Monnier
2012-11-06 11:03         ` Kim Storm
2012-11-06 15:38           ` Dmitry Gutov
2012-11-06 16:45             ` Kim Storm
2012-11-07  5:41           ` Dmitry Gutov
2012-11-05 20:57 ` Dmitry Gutov
2012-11-07  2:27   ` Leo
2012-11-07  4:06     ` Dmitry Gutov
2012-11-07 10:38       ` Leo
2012-11-07 21:54         ` Dmitry Gutov
2012-11-08  2:00           ` Leo
2012-11-08  4:14             ` Stefan Monnier
2012-11-08  7:36               ` Leo
2012-11-08 14:05                 ` Stefan Monnier
2012-11-10 17:52                   ` Dmitry Gutov
2012-11-10 22:51                     ` Stefan Monnier
2012-11-10 23:01                       ` Dmitry Gutov
2012-11-10 23:31                         ` Stefan Monnier
2020-09-13 16:14                       ` Lars Ingebrigtsen
2012-11-08  2:05       ` Stefan Monnier
2012-11-08  4:29         ` Dmitry Gutov [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=509B351F.8040607@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=12796@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sdl.web@gmail.com \
    --cc=storm@cua.dk \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).