"Arjan van Staalduijnen" <<Arjan.van.Staalduijnen[at]rtl.nl>> wrote:
>> In some if-statements I rewrote some or-statements to something like:
>> if ( (< "a", "b", "c" >)[ val ] ) {}
>> instead of:
>> if ( val == "a" || val == "b" || val == "c" ) {}
>> because, apart from being shorter, I assumed it would be more efficient.
>> Wrong again, or is the multiset way the most-efficient way here?
>
> ...or maybe rewrite it to:
> if ( ([ "a":1,"b":1,"c":1 ])[ val ] ) {}
When the sets are so small I don't think one can draw any conclusions
without measuring the three variants. I often use the multiset variety
because it's shorter and involves less pike level ops.
|