From: Hans Verkuil <hverkuil@xs4all.nl>
To: Rosen Penev <rosenp@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] v4l-utils: switch remote_subtest arrays to vector
Date: Tue, 20 Apr 2021 13:08:52 +0200 [thread overview]
Message-ID: <79e73829-332f-7e04-e419-3bb92f178d60@xs4all.nl> (raw)
In-Reply-To: <7A4EAA2C-9A31-4A3F-8ABA-8FE4F9D38980@gmail.com>
On 20/04/2021 12:13, Rosen Penev wrote:
>
>> On Apr 20, 2021, at 02:54, Hans Verkuil <hverkuil@xs4all.nl> wrote:
>>
>> Hi Rosen,
>>
>>> On 20/04/2021 06:27, Rosen Penev wrote:
>>> Easier to read and allows removing some boilerplate code. Only a
>>> moderate size increase.
>>>
>>> Ran through git clang-format
>>
>> Just to clarify: this is a clean up patch, right? There are no clang fixes
>> here as in your past patches.
> Not directly no. I initially wanted to use std::array and constexpr but could not because of the size parameter. vector is good enough I think.
>>
>>>
<snip>
>>> @@ -1553,32 +1486,31 @@ void testRemote(struct node *node, unsigned me, unsigned la, unsigned test_tags,
>>>
>>> int ret = 0;
>>>
>>> - for (const auto &test : tests) {
>>> + for (auto &&test : tests) {
>>
>> Why use 'auto &&test' instead of 'const auto &test'? Is there a good reason
>> for that? The original is much more readable and from what I understand just
>> as efficient (not that efficiency is an issue here).
>>
>> The same for other occurences of this idiom.
> In a different project, I replaced all range loops to use auto&& and got a size decrease. I don’t have a good explanation for it. Maybe it helps with copy elision which const can sometimes prevent. Not sure.
>
> My understanding of auto&& is that it evaluates to const ref, then ref, then value in that order.
Please keep the original. It is easier to understand, and that is more important
than saving a few bytes.
I read elsewhere after googling this construct that it is not recommended, unless
there is a really good reason for it.
Regards,
Hans
prev parent reply other threads:[~2021-04-20 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-20 4:27 [PATCH] v4l-utils: switch remote_subtest arrays to vector Rosen Penev
2021-04-20 9:54 ` Hans Verkuil
2021-04-20 10:13 ` Rosen Penev
2021-04-20 11:08 ` Hans Verkuil [this message]
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=79e73829-332f-7e04-e419-3bb92f178d60@xs4all.nl \
--to=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=rosenp@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 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).