Re: [PATCH v2] for_each_string_list_item: avoid undefined behavior for empty list
- From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
- Date
- Sep 20, 2017, 07:40 UTC
- Message-ID
- <b53ab56f-80e6-588f-fefb-53d7fe22edbd@gmail.com>
- In-Reply-To
- <20170920052705.GC126984@aiede.mtv.corp.google.com>
On Wednesday 20 September 2017 10:57 AM, Jonathan Nieder wrote:
> Guard the loop with a NULL check to make the intent crystal clear to > even the most pedantic compiler. A suitably clever compiler could let > the NULL check only run in the first iteration,
Noted this just now. So, the overhead doesn't occur when the compilers are clever enough. And as I said in my previous email to this thread, at least 'gcc' and 'clang' seem to be clever enough.
> ... but regardless, this > overhead is likely to be dwarfed by the work to be done on each item.
:-) That's of course seems to be true.