From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/3] diffcore-pickaxe: port optimization from has_changes() to diff_grep()
Date: Thu, 4 Apr 2013 21:45:24 -0700 [thread overview]
Message-ID: <1365137126-21659-1-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <7v1uapfuyp.fsf@alter.siamese.dyndns.org>
These two functions are called in the same codeflow to implement
"log -S<block>" and "log -G<pattern>", respectively, but the latter
lacked two obvious optimizations the former implemented, namely:
- When a pickaxe limit is not given at all, they should return
without wasting any cycle;
- When both sides of the filepair are the same, and the same
textconv conversion apply to them, return early, as there will be
no interesting differences between the two anyway.
Also release the filespec data once the processing is done (this is
not about leaking memory--it is about releasing data we finished
looking at as early as possible).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diffcore-pickaxe.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 26ddf00..bfaabab 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -83,7 +83,7 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
mmfile_t mf1, mf2;
int hit;
- if (diff_unmodified_pair(p))
+ if (!o->pickaxe[0])
return 0;
if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
@@ -91,6 +91,9 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
textconv_two = get_textconv(p->two);
}
+ if (textconv_one == textconv_two && diff_unmodified_pair(p))
+ return 0;
+
mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);
mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);
@@ -125,6 +128,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
free(mf1.ptr);
if (textconv_two)
free(mf2.ptr);
+ diff_free_filespec_data(p->one);
+ diff_free_filespec_data(p->two);
return hit;
}
--
1.8.2-588-gbf1c992
next prev parent reply other threads:[~2013-04-05 4:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-04 8:34 [BUG] git log -S not respecting --no-textconv Matthieu Moy
2013-04-04 16:03 ` [PATCH 1/2] diffcore-pickaxe: respect --no-textconv Simon Ruderich
2013-04-04 17:03 ` Matthieu Moy
2013-04-04 17:43 ` Jeff King
2013-04-04 17:45 ` Junio C Hamano
2013-04-04 17:51 ` Jeff King
2013-04-04 18:10 ` Junio C Hamano
2013-04-04 20:20 ` [PATCH v2 1/3] diffcore-pickaxe: remove unnecessary call to get_textconv() Simon Ruderich
2013-04-04 20:48 ` Junio C Hamano
2013-04-04 21:10 ` Junio C Hamano
2013-04-04 21:11 ` Jeff King
2013-04-04 22:51 ` Junio C Hamano
2013-04-05 13:20 ` Simon Ruderich
2013-04-04 20:21 ` [PATCH v2 2/3] diffcore-pickaxe: remove fill_one() Simon Ruderich
2013-04-05 0:08 ` Jeff King
2013-04-05 4:43 ` Junio C Hamano
2013-04-05 4:45 ` Junio C Hamano [this message]
2013-04-05 4:45 ` [PATCH 2/3] diffcore-pickaxe: fix leaks in "log -S<block>" and "log -G<pattern>" Junio C Hamano
2013-04-05 4:45 ` [PATCH 3/3] diffcore-pickaxe: unify setup and teardown code between log -S/-G Junio C Hamano
2013-04-05 5:28 ` Jeff King
2013-04-05 5:43 ` Junio C Hamano
2013-04-05 5:45 ` Jeff King
2013-04-05 16:44 ` Junio C Hamano
2013-04-04 20:21 ` [PATCH v2 3/3] diffcore-pickaxe: respect --no-textconv Simon Ruderich
2013-04-05 7:40 ` Matthieu Moy
2013-04-05 13:16 ` [PATCH v3 " Simon Ruderich
2013-04-05 17:31 ` 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=1365137126-21659-1-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.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).