Re: [PATCH] Make strbuf_cmp inline, constify its arguments and optimize it a bit

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Miles Bader
Date: Sunday, October 7, 2007 - 8:46 am

Pierre Habouzit <madcoder@debian.org> writes:

Couldn't you then just do:

   int len = a->len < b->len ? a->len : b->len;
   int cmp = memcmp(a->buf, b->buf, len);
   if (cmp == 0)
      cmp = b->len - a->len;
   return cmp;

[In the case where one string is a prefix of the other, then the longer
one is "greater".]

?

-Miles

-- 
"Suppose He doesn't give a shit?  Suppose there is a God but He
just doesn't give a shit?"  [George Carlin]
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
mini-refactor in rerere.c, Pierre Habouzit, (Mon Sep 24, 2:25 am)
[PATCH 1/2] Add strbuf_cmp., Pierre Habouzit, (Mon Sep 24, 2:25 am)
Re: [PATCH 2/2] Make builtin-rerere use of strbuf nicer an ..., Johannes Schindelin, (Mon Sep 24, 3:38 am)
Re: [PATCH] Make strbuf_cmp inline, constify its arguments ..., Miles Bader, (Sun Oct 7, 8:46 am)
Re: [PATCH] Make strbuf_cmp inline, constify its arguments ..., Johannes Schindelin, (Sun Oct 7, 9:11 am)
Re: [PATCH] Make strbuf_cmp inline, constify its arguments ..., Johannes Schindelin, (Sun Oct 7, 11:25 am)