From: Liu Yubao <yubao.liu@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] remove unnecessary loop
Date: Tue, 08 May 2007 11:18:31 +0800 [thread overview]
Message-ID: <463FEC07.8080605@gmail.com> (raw)
Hi,
Here is a minor optimization, the involved second "for" loop doesn't
need to start from beginning.
Signed-off-by: Liu Yubao <yubao.liu@gmail.com>
---
builtin-add.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 5e6748f..9d10fdc 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -239,20 +239,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
die("index file corrupt");
if (!ignored_too) {
- int has_ignored = 0;
for (i = 0; i < dir.nr; i++)
if (dir.entries[i]->ignored)
- has_ignored = 1;
- if (has_ignored) {
+ break;
+ if (i < dir.nr) {
fprintf(stderr, ignore_warning);
- for (i = 0; i < dir.nr; i++) {
+ do {
if (!dir.entries[i]->ignored)
continue;
fprintf(stderr, "%s", dir.entries[i]->name);
if (dir.entries[i]->ignored_dir)
fprintf(stderr, " (directory)");
fputc('\n', stderr);
- }
+ } while (++i < dir.nr);
fprintf(stderr,
"Use -f if you really want to add them.\n");
exit(1);
--
1.5.2.rc0.95.ga0715-dirty
next reply other threads:[~2007-05-08 3:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-08 3:18 Liu Yubao [this message]
2007-05-08 4:49 ` [PATCH] remove unnecessary loop Liu Yubao
2007-05-08 5:05 ` Junio C Hamano
2007-05-08 9:08 ` Alex Riesen
2007-05-08 10:13 ` Jan Hudec
2007-05-08 12:38 ` Alex Riesen
2007-05-08 12:17 ` Eric Blake
2007-05-08 9:39 ` Jan Hudec
2007-05-09 1:03 ` Liu Yubao
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=463FEC07.8080605@gmail.com \
--to=yubao.liu@gmail.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 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.