On 11.12.2011, at 20:48, Peter Maydell <peter.mayd...@linaro.org> wrote:

> On 11 December 2011 19:30, Christoffer Dall
> <c.d...@virtualopensystems.com> wrote:
>> On Sun, Dec 11, 2011 at 11:03 AM, Peter Maydell
>> <peter.mayd...@linaro.org> wrote:
>>> Removing the mask would be wrong since the irq field here
>>> is encoding both cpu number and irq-vs-fiq. The default is
>>> just an unreachable condition. (Why are we using % here
>>> rather than the obvious bit operation, incidentally?)
>>> 
>> right, I will remove the default case.
>> 
>> I highly doubt that the difference in using a bitop will be measurably
>> more efficient, but if you feel strongly about it, I can change it to
>> a shift and bitwise and, which I assume is what you mean by the
>> obvious bit operation? I think my CS background speaks for using %,
>> but whatever.
> 
> Certainly the compiler ought to be able to figure out the
> two are the same thing; I just think "irq & 1" is more readable
> than "irq % 2" (because it's being clear that it's treating the
> variable as a pile of bits rather than an integer). This is
> bikeshedding rather, though, and style issues in kernel code
> are a matter for the kernel folk. So you can ignore me :-)

Yes, the general rule of thumb is to use bit operations where you can. And in 
this case it certainly makes sense :).

Plus, bit operations are an order of magnitude faster than div/mod usually.


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to