qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] FDC: simplify code


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH] FDC: simplify code
Date: Sun, 6 Apr 2008 09:36:54 +0300

On 4/2/08, Hervé Poussineau <address@hidden> wrote:
> Hervé Poussineau a écrit :
>
>
> > Hi,
> >
> > This patch follows a patch I sent on 2008-03-31:
> >
> http://lists.gnu.org/archive/html/qemu-devel/2008-03/msg00510.html
> > Previous patch is required before applying this one.
> >
> > This patch prevents duplication of quite similar code, and so, removes 300
> lines and 8KB of code.
>  +    struct {
>  +        uint8_t value;
>  +        uint8_t mask;
>  +        const char* name;
>  +        int parameters;
>  +        void (*handler)(fdctrl_t *fdctrl, int direction);
>  +        int parameter;
>  +    } commands[] = {

This should be static const.

>  +        for (pos = 0; pos <
> sizeof(commands)/sizeof(commands[0]); pos++) {

The original code used constant mask and switch. Linear search could
be slower. Could you replace the search with a direct table lookup?

reply via email to

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