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>,
linux-gpio@vger.kernel.org
Subject: Re: [libgpiod v2][PATCH v6 5/5] bindings: cxx: add implementation
Date: Wed, 27 Apr 2022 14:01:53 +0800 [thread overview]
Message-ID: <20220427060153.GB118500@sol> (raw)
In-Reply-To: <20220426125023.2664623-6-brgl@bgdev.pl>
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.
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().
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>
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.
Cheers,
Kent.
next prev parent reply other threads:[~2022-04-27 6:02 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 [this message]
2022-05-02 12:34 ` Bartosz Golaszewski
2022-05-02 13:54 ` Kent Gibson
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=20220427060153.GB118500@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 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.