From: Mustafa Orkun Acar <mustafaorkunacar@gmail.com>
To: sunshine@sunshineco.com, git@vger.kernel.org
Cc: Mustafa Orkun Acar <mustafaorkunacar@gmail.com>
Subject: [PATCH v2] Rewrite strbuf.c:strbuf_cmp() replace memcmp() with starts_with()
Date: Sat, 22 Mar 2014 23:25:16 +0200 [thread overview]
Message-ID: <1395523516-10181-1-git-send-email-mustafaorkunacar@gmail.com> (raw)
I reviewed all functions using memcmp(). It generally makes code more understandable. But here it might be used for the sake of simplicity.
Signed-off-by: Mustafa Orkun Acar <mustafaorkunacar@gmail.com>
---
I applied to GSoC 2014. I expect your feedbacks and comments!
strbuf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/strbuf.c b/strbuf.c
index ee96dcf..50d0875 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -147,7 +147,7 @@ void strbuf_list_free(struct strbuf **sbs)
int strbuf_cmp(const struct strbuf *a, const struct strbuf *b)
{
int len = a->len < b->len ? a->len: b->len;
- int cmp = memcmp(a->buf, b->buf, len);
+ int cmp = !starts_with(a->buf, b->buf);
if (cmp)
return cmp;
return a->len < b->len ? -1: a->len != b->len;
--
1.9.1.286.g5172cb3
next reply other threads:[~2014-03-22 21:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-22 21:25 Mustafa Orkun Acar [this message]
2014-03-22 21:58 ` [PATCH v2] Rewrite strbuf.c:strbuf_cmp() replace memcmp() with starts_with() Alexandru Guduleasa
2014-03-22 21:58 ` David Kastrup
2014-03-23 9:02 ` Eric Sunshine
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=1395523516-10181-1-git-send-email-mustafaorkunacar@gmail.com \
--to=mustafaorkunacar@gmail.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.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;
as well as URLs for NNTP newsgroup(s).