summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e392a85)
raw | patch | inline | side by side (parent: e392a85)
author | Alex Riesen <raa.lkml@gmail.com> | |
Thu, 19 Mar 2009 22:27:32 +0000 (23:27 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 20 Mar 2009 16:35:32 +0000 (09:35 -0700) |
It can be less object code and may be even faster, even if at the
moment there is no callers to take an advantage of that. This
implementation can be trivially made inlinable later.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
moment there is no callers to take an advantage of that. This
implementation can be trivially made inlinable later.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strbuf.c | patch | blob | history |
diff --git a/strbuf.c b/strbuf.c
index 6ed06840b856a91f6d215c9a862e064f521384f0..bfbd81632e8d2e5584c4eeac0d17aa4b4c2525d8 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
int strbuf_cmp(const struct strbuf *a, const struct strbuf *b)
{
- int cmp;
- if (a->len < b->len) {
- cmp = memcmp(a->buf, b->buf, a->len);
- return cmp ? cmp : -1;
- } else {
- cmp = memcmp(a->buf, b->buf, b->len);
- return cmp ? cmp : a->len != b->len;
- }
+ int len = a->len < b->len ? a->len: b->len;
+ int cmp = memcmp(a->buf, b->buf, len);
+ if (cmp)
+ return cmp;
+ return a->len < b->len ? -1: a->len != b->len;
}
void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,