From: Benjamin Kramer <benny.kra@googlemail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Fredrik Kuivinen <frekui@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Johannes Sixt <j.sixt@viscovery.net>
Subject: Re: [PATCH v4] Threaded grep
Date: Tue, 26 Jan 2010 17:30:12 +0100 [thread overview]
Message-ID: <4B5F1894.4070509@googlemail.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1001260728260.3574@localhost.localdomain>
BSD and glibc have an extension to regexec which takes a buffer + length pair
instead of a NUL-terminated string. Since we already have the length
computed this can save us a strlen call.
---
On 26.01.10 16:28, Linus Torvalds wrote:
> so it's sadly internal to regex. It would be nice if there was a
> non-string interface to regexec (ie a "buffer + length" instead of a
> NUL-terminated string).
BSD and glibc have an "REG_STARTEND" flag to do that. I made a small
PoC patch to use it if it's available but it didn't give any significant
speedup on my system.
grep.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/grep.c b/grep.c
index d281a02..60cce46 100644
--- a/grep.c
+++ b/grep.c
@@ -675,8 +675,15 @@ static int look_ahead(struct grep_opt *opt,
if (p->fixed)
hit = !fixmatch(p->pattern, bol, p->ignore_case, &m);
- else
+ else {
+#ifdef REG_STARTEND
+ m.rm_so = 0;
+ m.rm_eo = *left_p;
+ hit = !regexec(&p->regexp, bol, 1, &m, REG_STARTEND);
+#else
hit = !regexec(&p->regexp, bol, 1, &m, 0);
+#endif
+ }
if (!hit || m.rm_so < 0 || m.rm_eo < 0)
continue;
if (earliest < 0 || m.rm_so < earliest)
--
1.7.0.rc0.12.gc33c3
next prev parent reply other threads:[~2010-01-26 16:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-25 22:51 [PATCH v4] Threaded grep Fredrik Kuivinen
2010-01-25 23:59 ` Linus Torvalds
2010-01-26 12:10 ` Fredrik Kuivinen
2010-01-26 15:28 ` Linus Torvalds
2010-01-26 16:30 ` Benjamin Kramer [this message]
2010-01-26 16:44 ` Linus Torvalds
2010-01-26 16:56 ` Linus Torvalds
2010-01-26 17:19 ` Mike Hommey
2010-01-26 17:48 ` [PATCH] grep: use REG_STARTEND (if available) to speed up regexec Benjamin Kramer
2010-01-26 1:20 ` [PATCH v4] Threaded grep Junio C Hamano
2010-01-26 11:43 ` Fredrik Kuivinen
2010-01-26 17:21 ` Junio C Hamano
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=4B5F1894.4070509@googlemail.com \
--to=benny.kra@googlemail.com \
--cc=frekui@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.net \
--cc=torvalds@linux-foundation.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.
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 NNTP newsgroup(s).