[Issue 6176] [TDPL] Cannot use string variables in case expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 19 13:50:20 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6176


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec


--- Comment #4 from Stewart Gordon <smjg at iname.com> 2011-06-19 13:45:32 PDT ---
(In reply to comment #2)
> I think currently DMD doesn't optimize string
> switches a lot, but it's not hard to think about it using a hard-coded trie,
> some kind of digital tree, perfect hashing, etc. Compile-time constants allow
> to create such optimized code.

But that doesn't mean it would have to _always_ use a hard-coded tree.  It goes
without saying that an optimisation can happen only if the criteria for it to
make sense are satisfied.  Let F be the overall feature being considered, and S
be the subset of this feature that can be optimised in a certain way.  Why
contrive F to equal S, when you can implement a non-empty F \ S just without
the optimisation?

If the case values are all constant, create this tree.  Otherwise, just compare
the switched value with the cases individually.

Later on, we could improve it to use a mixture of the two approaches where some
but not all cases are CTCs.

-- 
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