[PATCH v2] Rewrite strbuf.c:strbuf_cmp() replace memcmp() with starts_with()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]