git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] Remove uneccessary strncmp call in imap-send count_messages
Date: Sun, 22 Oct 2006 15:53:28 +0100	[thread overview]
Message-ID: <200610221553.28872.andyparkins@gmail.com> (raw)

The strncmp() call in count_messages() was doing the same comparison that 
strstr() did, so there was no need to call it.  A little rewrite and 
count_messages() is simpler.

Obviously no huge benefit, as it's not frequently called.  I'm just getting 
familiar with git.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 imap-send.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 16804ab..cfac17b 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1198,15 +1198,14 @@ count_messages( msg_data_t *msg )
 	int count = 0;
 	char *p = msg->data;
 
-	while (1) {
-		if (!strncmp( "From ", p, 5 )) {
-			count++;
+	while (p) {
+		p = strstr( p, "From " );
+		if ( p != NULL ) {
+			if ( p == msg->data || *(p-1) == '\n' ) {
+				count++;
+			}
 			p += 5;
 		}
-		p = strstr( p+5, "\nFrom ");
-		if (!p)
-			break;
-		p++;
 	}
 	return count;
 }
-- 
1.4.2.3

                 reply	other threads:[~2006-10-22 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200610221553.28872.andyparkins@gmail.com \
    --to=andyparkins@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 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).