{"thread":{"id":"6001","subject":"[PATCH] Remove uneccessary strncmp call in imap-send count_messages","startedAt":"2006-10-22T14:53:28Z","lastAt":"2006-10-22T14:53:28Z","messageCount":1,"participants":["Andy Parkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"29640","messageId":"200610221553.28872.andyparkins@gmail.com","threadId":"6001","inReplyTo":null,"subject":"[PATCH] Remove uneccessary strncmp call in imap-send count_messages","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-10-22T14:53:28Z","receivedAt":"2006-10-22T14:53:28Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"The strncmp() call in count_messages() was doing the same comparison that \nstrstr() did, so there was no need to call it.  A little rewrite and \ncount_messages() is simpler.\n\nObviously no huge benefit, as it's not frequently called.  I'm just getting \nfamiliar with git.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n imap-send.c |   13 ++++++-------\n 1 files changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/imap-send.c b/imap-send.c\nindex 16804ab..cfac17b 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1198,15 +1198,14 @@ count_messages( msg_data_t *msg )\n \tint count = 0;\n \tchar *p = msg->data;\n \n-\twhile (1) {\n-\t\tif (!strncmp( \"From \", p, 5 )) {\n-\t\t\tcount++;\n+\twhile (p) {\n+\t\tp = strstr( p, \"From \" );\n+\t\tif ( p != NULL ) {\n+\t\t\tif ( p == msg->data || *(p-1) == '\\n' ) {\n+\t\t\t\tcount++;\n+\t\t\t}\n \t\t\tp += 5;\n \t\t}\n-\t\tp = strstr( p+5, \"\\nFrom \");\n-\t\tif (!p)\n-\t\t\tbreak;\n-\t\tp++;\n \t}\n \treturn count;\n }\n-- \n1.4.2.3\n"}]}