X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=strbuf.c;h=bfbd81632e8d2e5584c4eeac0d17aa4b4c2525d8;hb=0b3035fe15bfd1d1f7cfab71819cb2cf4fc40d61;hp=6ed06840b856a91f6d215c9a862e064f521384f0;hpb=500ff119682eaa6d5047b40e54688219a57716ca;p=git.git diff --git a/strbuf.c b/strbuf.c index 6ed06840b..bfbd81632 100644 --- a/strbuf.c +++ b/strbuf.c @@ -139,14 +139,11 @@ void strbuf_list_free(struct strbuf **sbs) 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,