Re: [PATCH 1/2] PCI: Update BAR # and window messages

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

 



On Fri, Nov 19, 2021 at 03:43:04PM -0600, Bjorn Helgaas wrote:
> On Sat, Nov 06, 2021 at 12:58:31PM +0100, Lukas Wunner wrote:
> > Use a static const array of char * instead of a switch/case ladder
> > to reduce LoC count and improve performance.
> 
> I tried converting this and came up with the below.  Is that the sort
> of thing you're thinking?  Gcc *does* generate slightly smaller code
> for it, but Puranjay's original source code is smaller and IMO a
> little easier to read.

Yes, that's what I had in mind.  Aside from binary or source code size,
retrieving the name from an array is just a quick direct access, whereas
a switch/case ladder becomes a lot of conditional branches in binary code,
which is slower.

Another option is to use case ranges.  See max3191x_set_config() in
drivers/gpio/gpio-max3191x.c for an example.  gcc is smart enough to
generate an optimized set of conditional greater-than / less-than branches.
That could be used to shorten your cardbus_name[] array.

Thanks,

Lukas



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux