linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Alexander Stein" <alexander.stein@mailbox.org>,
	"David Kozub" <zub@linux.fjfi.cvut.cz>,
	"Jan Kundrát" <jan.kundrat@cesnet.cz>,
	"Michael Beach" <michaelb@ieee.org>,
	"Jack Winch" <sunt.un.morcov@gmail.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod v2][PATCH v6 5/5] bindings: cxx: add implementation
Date: Mon, 2 May 2022 21:54:12 +0800	[thread overview]
Message-ID: <20220502135412.GA16365@sol> (raw)
In-Reply-To: <CAMRc=McZirBT_sdWxrhVomUoODTb-tz-og86Zf6KY4BBMXOw7Q@mail.gmail.com>

On Mon, May 02, 2022 at 02:34:34PM +0200, Bartosz Golaszewski wrote:
> On Wed, Apr 27, 2022 at 8:02 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Tue, Apr 26, 2022 at 02:50:23PM +0200, Bartosz Golaszewski wrote:
> > > This contains the actual implementation of the v2 C++ bindings.
> > >
> > > Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> >
> > [snip]
> >
> > > +
> > > +GPIOD_CXX_API ::std::size_t line_request::num_lines(void) const
> > > +{
> > > +     this->_m_priv->throw_if_released();
> > > +
> > > +     return ::gpiod_line_request_get_num_lines(this->_m_priv->request.get());
> > > +}
> > > +
> > > +GPIOD_CXX_API line::offsets line_request::offsets(void) const
> > > +{
> > > +     this->_m_priv->throw_if_released();
> > > +
> > > +     ::std::vector<unsigned int> buf(this->num_lines());
> > > +     line::offsets offsets(this->num_lines());
> > > +
> > > +     ::gpiod_line_request_get_offsets(this->_m_priv->request.get(), buf.data());
> > > +
> > > +     auto num_lines = this->num_lines();
> > > +     for (unsigned int i = 0; i < num_lines; i++)
> > > +             offsets[i] = buf[i];
> > > +
> > > +     return offsets;
> > > +}
> > > +
> >
> > My previous comment was "Cache num_lines locally rather than calling
> > num_lines() several times."
> >
> > You cached it in the wrong place - it should be first thing in the
> > function, so you only call it once, not three times.
> >
> 
> I fixed it when applying.
> 
> > And the throw_if_released() is still "redundant as this->num_lines()
> > also does it", and it is the first thing called here - after the
> > throw_if_released().
> >
> 
> I think it's still worth having it here because at least the code
> makes it clear, we need to have a valid request here. It's not like
> it's a hot path where this additional function call would matter IMO.
> 

So add a comment?
Pointless work is pointless work, hot path or not.

> > And I would've made this patch 3/5, not 5/5.
> >
> > But I'm fine with this set going in either way - in fact give its size
> > I'd rather see minor tweaks applied later than go through another round
> > of review.
> >
> > For the series:
> >
> > Reviewed-by: Kent Gibson <warthog618@gmail.com>
> 
> Thanks I applied it for now as it is, let's get it into master with
> the Python bindings and then polish it some more there.
> 
> >
> > I really would also like to see some feedback from C++ developers that
> > will actually be using it, as they have a bigger stake in it than I do.
> > But that is up to them.
> >
> 
> Indeed, any idea where to post that to get some free code reviews from
> C++ devs? :)
> 

That does raise the issue of whether libgpiod should have a forum other
than this mailing list.

I was hoping to at least nudge the others on the CC list ¯\_(ツ)_/¯.
If no one is sufficiently interested to bother reviewing, or even acking,
the C++ bindings, perhaps deprecate them instead ;-)?

Cheers,
Kent.

  reply	other threads:[~2022-05-02 13:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26 12:50 [libgpiod v2][PATCH v6 0/5] bindings: cxx: implement C++ bindings for libgpiod v2.0 Bartosz Golaszewski
2022-04-26 12:50 ` [libgpiod v2][PATCH v6 1/5] bindings: cxx: remove old code Bartosz Golaszewski
2022-04-26 12:50 ` [libgpiod v2][PATCH v6 2/5] bindings: cxx: add v2 headers Bartosz Golaszewski
2022-05-05  8:20   ` Bartosz Golaszewski
2022-04-26 12:50 ` [libgpiod v2][PATCH v6 3/5] bindings: cxx: add v2 tests Bartosz Golaszewski
2022-04-26 12:50 ` [libgpiod v2][PATCH v6 4/5] bindings: cxx: add examples Bartosz Golaszewski
2022-04-26 12:50 ` [libgpiod v2][PATCH v6 5/5] bindings: cxx: add implementation Bartosz Golaszewski
2022-04-27  6:01   ` Kent Gibson
2022-05-02 12:34     ` Bartosz Golaszewski
2022-05-02 13:54       ` Kent Gibson [this message]
2022-05-02 17:41         ` Bartosz Golaszewski
2022-05-03  8:04           ` Kent Gibson

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=20220502135412.GA16365@sol \
    --to=warthog618@gmail.com \
    --cc=alexander.stein@mailbox.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=jan.kundrat@cesnet.cz \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=michaelb@ieee.org \
    --cc=sunt.un.morcov@gmail.com \
    --cc=viresh.kumar@linaro.org \
    --cc=zub@linux.fjfi.cvut.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).