From: "Davis Herring" <herring@lanl.gov>
To: "Lennart Borgman" <lennart.borgman@gmail.com>
Cc: emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
Drew Adams <drew.adams@oracle.com>, Leo <sdl.web@gmail.com>
Subject: Re: `completion-in-region'
Date: Mon, 12 Apr 2010 07:50:40 -0700 (PDT) [thread overview]
Message-ID: <33121.130.55.118.19.1271083840.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <z2me01d8a51004120246q1ea43e11m76e967f32886531c@mail.gmail.com>
> I do not understand the "for each" here. I thought that since ".*?" is
> greedy that means that only the first "a" could match.
(Stefan spoke to this.)
> But maybe I am missing that the first ".*?" is not anchored. Would
> "^.*?a.*?b.*?c" behave differently?
You're right, actually, that this would help (though again the ?s are
irrelevant). A search (as opposed to a match; `looking-at' is a match,
but (confusingly) `string-match' is a search) with the regexp ".*a.*b.*c"
will be O(N^4) in the length of the subject string because the search will
look for a c for each b match, a b for each a match, and an a for each
distance from the search point, and will search starting from each
position in the string.
Anchoring the search (which turns it into a match, effectively) removes
that last, outermost layer, and so reduces the complexity to N^3.
However, I would implement this "fuzzy" search with just "a.*b.*c", which
has the same N^3 behavior without the "^.*" prefix that doesn't get you
anything. (Of course, if it were implemented as a match, then the leading
.* would be necessary, the ^ would be superfluous, and the complexity
would still be N^3.)
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
next prev parent reply other threads:[~2010-04-12 14:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-06 14:37 `completion-in-region' Leo
2010-04-09 3:05 ` `completion-in-region' Stefan Monnier
2010-04-11 12:56 ` `completion-in-region' Leo
2010-04-11 15:32 ` `completion-in-region' Stefan Monnier
2010-04-11 18:05 ` `completion-in-region' Drew Adams
2010-04-11 19:44 ` `completion-in-region' Stefan Monnier
2010-04-11 19:56 ` `completion-in-region' Drew Adams
2010-04-11 20:49 ` `completion-in-region' Stefan Monnier
2010-04-11 21:13 ` `completion-in-region' Drew Adams
2010-04-11 20:08 ` `completion-in-region' Lennart Borgman
2010-04-11 20:51 ` `completion-in-region' Stefan Monnier
2010-04-11 21:06 ` `completion-in-region' Lennart Borgman
2010-04-12 2:10 ` `completion-in-region' Stefan Monnier
2010-04-12 9:46 ` `completion-in-region' Lennart Borgman
2010-04-12 13:10 ` `completion-in-region' Stefan Monnier
2010-04-12 14:50 ` Davis Herring [this message]
2010-04-11 21:12 ` `completion-in-region' Drew Adams
2010-04-12 15:36 ` `completion-in-region' Leo
2010-04-12 18:10 ` `completion-in-region' Stefan Monnier
2010-04-12 15:51 ` `completion-in-region' Leo
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=33121.130.55.118.19.1271083840.squirrel@webmail.lanl.gov \
--to=herring@lanl.gov \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=lennart.borgman@gmail.com \
--cc=monnier@iro.umontreal.ca \
--cc=sdl.web@gmail.com \
/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.