[Top][All Lists]
[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
Re: [Qemu-devel] [PATCH 0/2] Allow '-' or '_' for all QemuOpts, Luiz Capitulino, 2012/07/25
Re: [Qemu-devel] [PATCH 0/2] Allow '-' or '_' for all QemuOpts, Markus Armbruster, 2012/07/27