Skip to content

Commit

Permalink
Unroll MIN as the straight ?: construct
Browse files Browse the repository at this point in the history
Considering that not all compilers give us MIN implicitly,
and since it's only at one place in the code, losing the MIN
shouldn't be too high a price to pay, readability-wise, for
portability.
  • Loading branch information
yanick committed May 26, 2013
1 parent e6f0ec9 commit 537cae8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion buffer.c
Expand Up @@ -242,7 +242,7 @@ void gh_buf_attach(gh_buf *buf, char *ptr, size_t asize)

int gh_buf_cmp(const gh_buf *a, const gh_buf *b)
{
int result = memcmp(a->ptr, b->ptr, MIN(a->size, b->size));
int result = memcmp(a->ptr, b->ptr, a->size < b->size ? a->size : b-> size);
return (result != 0) ? result :
(a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0;
}
Expand Down

0 comments on commit 537cae8

Please sign in to comment.