qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 4/8] target/mips: Avoid case statements formu


From: Aleksandar Markovic
Subject: Re: [Qemu-devel] [PATCH v3 4/8] target/mips: Avoid case statements formulated by ranges
Date: Fri, 6 Jul 2018 09:04:48 +0000

> >      case 18:
> >          switch (sel) {
> > -        case 0 ... 7:
> > +        case 0:
> > +        case 1:
> > +        case 2:
> > +        case 3:
> > +        case 4:
> > +        case 5:
> > +        case 6:
> > +        case 7:
>
> I don't see the point in this.  It is clear what 0 ... 7 means.

The point is to avoid using ranges altogether, regardless of the clarity of a 
particular instance.

Let me further explain the reason: Consider this: Let's say we plan to replace 
0, 1, 2, 3, 4, 5, 6, 7 with some preprocessor constants, appropriate for the 
particular context. If we keep "0 ... 7" notation, that line will look like 
"case ABC_KLM ... ABC_RST:" and will suddenly become much less clear.

As a mattter of fact, there is a plan to switch from hardcoded numbers to 
preprocessor constants in this instance, but it is a low priority task.

Regards,
Aleksandar


reply via email to

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