[MPlayer-dev-eng] [PATCH] clean up tests in configure

Corey Hickey bugfood-ml at fatooh.org
Fri Jun 10 10:53:25 CEST 2005


Guillaume POIRIER wrote:
>>I recently came upon this:
>>
>>[ "$cc_vendor" = "gnu" ] && ([ "$_cc_major" -gt 3 ] || ( [ "$_cc_major"
>>= 3 ] && [ "$_cc_minor" -ge 4 ]))
>>
>>...over which I prefer:
>>
>>test "$cc_vendor" = "gnu" && test "$_cc_major" -gt 3 -o "$_cc_major" -eq
>>3 -a "$_cc_minor" -ge 4
> 
> 
> That's just me, but I really prefer the original version, which is a
> lot more readable to me.
> 

The original version uses two subshells and four test invocations. My
version uses no subshells and only two tests.

One of the subshells in the original version is unnecessary, as,
according to my experimentation, && has higher precedence than ||. So,
it could be written as:

[ "$cc_vendor" = "gnu" ] && ([ "$_cc_major" -gt 3 ] || [ "$_cc_major"
= 3 ] && [ "$_cc_minor" -ge 4 ])

The other subshell is still needed to force the desired order of
evaluation. Combining the last three tests removes this necessity.

Now, arguably, I've just wasted more time rationalizing the change than
everybody's computers ever wasted dealing with the overhead of making a
couple extra subshells, but I'd still prefer the improvement. That my
version is cleaner remains my opinion.

:)

For now, though, I'd better go to sleep.

-Corey




More information about the MPlayer-dev-eng mailing list