All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Puranjay Mohan <puranjay12@gmail.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/2] PCI: Update BAR # and window messages
Date: Wed, 24 Nov 2021 05:28:10 +0100	[thread overview]
Message-ID: <20211124042810.GB1887@wunner.de> (raw)
In-Reply-To: <20211119214304.GA1963177@bhelgaas>

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

  reply	other threads:[~2021-11-24  4:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-06 11:26 [PATCH 0/2] PCI: Update BAR #/window messages Puranjay Mohan
2021-11-06 11:26 ` [PATCH 1/2] PCI: Update BAR # and window messages Puranjay Mohan
2021-11-06 11:58   ` Lukas Wunner
2021-11-19 21:43     ` Bjorn Helgaas
2021-11-24  4:28       ` Lukas Wunner [this message]
2021-11-06 11:26 ` [PATCH 2/2] PCI: Use resource names in PCI log messages Puranjay Mohan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211124042810.GB1887@wunner.de \
    --to=lukas@wunner.de \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=puranjay12@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.