From: Kaartic Sivaraam Date: Wed, 20 Sep 2017 07:40:35 GMT Subject: Re: [PATCH v2] for_each_string_list_item: avoid undefined behavior for empty list Message-ID: 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.