Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unroll MIN as the straight ?: construct #13

Open
wants to merge 1 commit into from

2 participants

@yanick

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.

@yanick yanick Unroll MIN as the straight ?: construct
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.
537cae8
@christianbundy

Just out of curiosity, which common compiler's don't give us MIN? I've been reading through the code in this repo and your PR sparked my interest. Thanks in advance!

@yanick

Look at the failures of Escape::Houdini 0.1.2 (my Perl wrapper for the houdini lib) at http://www.cpantesters.org/distro/E/Escape-Houdini.html As usual, it's the windows compiler that seems to be causing problems, the naughty git. :-)

@christianbundy

Thanks for the explanation! I'm going to maintain an updated fork of @vmg's project over at christianbundy/houdini, and I've merged your commit.

@yanick

Sweet. The Perl module was using my own fork. I'm glad to ear I'll be able to just point to yours and have one less repo to worry about. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 26, 2013
  1. @yanick

    Unroll MIN as the straight ?: construct

    yanick authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  buffer.c
View
2  buffer.c
@@ -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;
}
Something went wrong with that request. Please try again.