[Ffmpeg-devel] [PATCH] Wildcard and catalog image sequences

Michel Bardiaux mbardiaux
Mon Sep 4 11:29:19 CEST 2006


M?ns Rullg?rd wrote:
> Michael Niedermayer said:
>> Hi
>>
>> On Wed, Aug 30, 2006 at 02:28:57PM +0200, Michel Bardiaux wrote:
>>> Michael Niedermayer wrote:
>>>> looking at for example:
>>>>
>>>>>> +int filename_catalog_test(const char *filename)
>>>>>> +{
>>>>>> +    if(!filename)
>>>>>> +        return (-1);
>>>>>> +    else if(filename[0]=='@')
>>>>>> +        return 0;
>>>>>> +    else
>>>>>> +        return (-1);
>>>> versus
>>>>
>>>>> return filename && filename[0]=='@';
>>>> i cant see how the later is more obfuscated, additionally
>>> I dont mean all one-liners are obfuscated, only that they quickly become
>>> so. Esp. since the correct one is
>>>
>>> return (filename && filename[0]=='@')?0:-1; // justified below.
>>>
>>> Still reasonable, but the one about wildcards is even bigger. If one has
>>> to code for multiple levels of conditions, nested ?: become quite
>>> unreadable. So there is a limit to one-liners, and where it is is a
>>> matter of taste, isnt it?
>> sure but my suggestion wouldnt need the ?: and without that the one liner
>> really seems to be the better solution
> 
> return -(filename && filename[0] == '@');

That gives -1 for OK and 0 for KO, the opposite of what is wanted!

Even an apparently simple one-liner can trip you. That is exactly why, 
in the code write or supervise for my customers, I strongly favor the 
multiple-if-lines style; particularly when there is *no* actual bloat 
resulting.

> 


-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list