David Kastrup writes:
> Junio C Hamano writes:
>
>> Michael Haggerty writes:
>>
>>> while (*path) {
>>> - const char *slash;
>>> struct cache_tree_sub *sub;
>>> + const char *slash = strchr(path, '/');
>>>
>>> - slash = strchr(path, '/');
>>>
Junio C Hamano writes:
> Michael Haggerty writes:
>
>> I really wish we could mix declarations with statements because I think
>> it is a big help to readability.
> ...
> Unfortunately, I think we are in violent disagreement.
After re-reading the above, I realize that my statement may have
soun
Junio C Hamano writes:
> Michael Haggerty writes:
>
>> while (*path) {
>> -const char *slash;
>> struct cache_tree_sub *sub;
>> +const char *slash = strchr(path, '/');
>>
>> -slash = strchr(path, '/');
>> if (!slash)
>>
Michael Haggerty writes:
>> Isn't the above a strchrnul()?
>
> Oh, cool, I never realized that this GNU extension was blessed for use
> in Git. Will change.
We do have our own fallbacks for non-glibc platforms, so it should
be safe.
>> Combining a freestanding decl with intializer assignment t
On 03/04/2014 10:05 PM, Junio C Hamano wrote:
> Michael Haggerty writes:
>
>> while (*path) {
>> -const char *slash;
>> struct cache_tree_sub *sub;
>> +const char *slash = strchr(path, '/');
>>
>> -slash = strchr(path, '/');
>>
Michael Haggerty writes:
> while (*path) {
> - const char *slash;
> struct cache_tree_sub *sub;
> + const char *slash = strchr(path, '/');
>
> - slash = strchr(path, '/');
> if (!slash)
> slash = path +
Michael Haggerty writes:
> BTW, I purposely didn't use a "for" loop at the end (even though I
> usually like them) because I wanted to keep it prominent that path is
> being updated to the value of slash. Putting that assignment in a for
> loop makes it easy to overlook because it puts "path" in
On 03/04/2014 10:40 AM, David Kastrup wrote:
> Michael Haggerty writes:
>
>> The beginning of the loop ensures that slash can never be NULL. So
>> don't keep checking whether it is NULL later in the loop.
>>
>> Furthermore, there is no need for an early
>>
>> return it;
>>
>> from the loop i
Michael Haggerty writes:
> The beginning of the loop ensures that slash can never be NULL. So
> don't keep checking whether it is NULL later in the loop.
>
> Furthermore, there is no need for an early
>
> return it;
>
> from the loop if slash points at the end of the string, because that
> i
The beginning of the loop ensures that slash can never be NULL. So
don't keep checking whether it is NULL later in the loop.
Furthermore, there is no need for an early
return it;
from the loop if slash points at the end of the string, because that
is exactly what will happen when the while
10 matches
Mail list logo