[Issue 6176] [TDPL] Cannot use string variables in case expressions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 20 15:16:00 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6176
--- Comment #6 from Stewart Gordon <smjg at iname.com> 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list