On 27 July 2012 08:44, Markus Armbruster <arm...@redhat.com> wrote:
> The implementation is too longwinded for my taste :)
>
> static unsigned char opt_canon_ch(char ch)
> {
>     if (ch >= 'A' && ch <= 'Z') {
>         return 'a' + (ch - 'A');
>     } else if (ch == '_') {
>         return '-';
>     }
>
>     return ch;
> }
>
> int qemu_opt_name_cmp(const char *lhs, const char *rhs)
> {
>     unsigned char l, r;
>
>     do {
>         l = opt_canon_ch(*lhs++);
>         r = opt_canon_ch(*rhs++);
>     } while (l && l == r);
>
>     return l - r;
> }

Yes, I like the function naming and this implementation
is both shorter and more obviously correct.

-- PMM

Reply via email to