--- Comment #6 from Stewart Gordon <> 2011-06-20 15:11:09 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
>> If the case values are all constant, create this tree.  
>> Otherwise, just compare the switched value with the cases 
>> individually.
> This is possible, of course, it just requires a bit more 
> complex compiler.

But the extra complexity is nothing compared to implementing the tree
optimisation in the first place.

Moreover, ISTM for switches with only a few values, comparing the cases
individually might be actually more efficient.  So this extra complexity might
actually be needed in order not to pessimise these simpler cases.

> A problem: if one of your strings are not compile-time const, because of a
> mistake of the programmer, there is a silent and invisible loss of 
> performance.

Which is to be expected.  After all, compiler optimisation is a privilege, not
a right.

Though adopting the aforementioned mixture of the two approaches would mean
that any loss of performance would be small.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to