Re: [PATCH v2] macos: lazily initialize iconv
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 31, 2012, 19:00 UTC
- Message-ID
- <7vwr1jiwn8.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAN0XMOKBPirJFzHM_QgDC8TGimoEhjWoAVA+JhaLzto4-SVvmw@mail.gmail.com>
Ralf Thielow <ralf.thielow@gmail.com> writes:
Show 10 quoted lines
> On Tue, Jul 31, 2012 at 8:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> + /* Avoid iconv_open()/iconv_close() if there is nothing to convert */
>> + for (i = 0; i < argc; i++) {
>> + if (has_utf8(argv[i], (size_t)-1, NULL))
>> + break;
>> + }
>> + if (argc <= i)
>> + return; /* no utf8 found */
>
> sorry, but "argc" can never be smaller than "i", right?Yeah, but it is idiomatic to have an inverse of the exit condition of the preceding for loop here to catch an early exit, and writing it as "if (i == argc)", while technically correct, would break the pattern.