From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] diff: try lazy read of config only once
Date: Fri, 4 Jan 2008 03:31:16 -0500 [thread overview]
Message-ID: <20080104083116.GA3354@coredump.intra.peff.net> (raw)
The function read_config_if_needed used a list pointer to
determined whether it had already been called. However, if
the user had no diff drivers, the function would repeatedly
read the config (typically once per diffed file).
Instead, let's use a signal variable so that we read it only
once (note that we may actually still read it an extra time,
since the config may already have been read outside of this
function). This reduces the cost of
git-whatchanged -p >/dev/null
from 34 seconds to 33 seconds.
Signed-off-by: Jeff King <peff@peff.net>
---
This are might be changed from the fallout of the other mail I just
sent, but I wanted to at least mention it. The speedup is not terribly
significant, but it just seems stupid to parse the config file thousands
of times. And I suspect on slow-I/O systems (like Cygwin) that it might
make more of a difference.
diff.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 5bdc111..f6a8515 100644
--- a/diff.c
+++ b/diff.c
@@ -61,10 +61,15 @@ static struct ll_diff_driver {
static void read_config_if_needed(void)
{
+ static int done = 0;
+ if (done)
+ return;
+
if (!user_diff_tail) {
user_diff_tail = &user_diff;
git_config(git_diff_ui_config);
}
+ done = 1;
}
/*
--
1.5.4.rc2.1122.g6954-dirty
next reply other threads:[~2008-01-04 8:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-04 8:31 Jeff King [this message]
2008-01-04 8:36 ` [PATCH] diff: try lazy read of config only once Junio C Hamano
2008-01-04 8:40 ` Jeff King
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=20080104083116.GA3354@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox