qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] qemu-opts: introduce a function to compare


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-opts: introduce a function to compare option names
Date: Fri, 27 Jul 2012 12:14:33 +0100

On 27 July 2012 08:44, Markus Armbruster <address@hidden> 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

[Prev in Thread] Current Thread [Next in Thread]