Simon Marlow writes:
> Alex Ferguson <[EMAIL PROTECTED]> writes:
> 
> > Is pattern-matching short strings (one or two characters) likely to be
> > _vastly_ less efficient than matching against a single level of
> > constructor?  (Order of magnitude, plus.)  Trying to make sense of some
> > profiling numbers, here...
> 
> Quite possibly - pattern matching on strings involves building a
> dictionary for Eq [Char], unpacking the string (it's represented as
> packed in the object code), and performing the comparison.  This is
> probably bad. 
> 

This is not always the case, string literals of length 0 and 1 are
expanded into list form, so

  f "a" =
  f ...

and

  f ('a':[]) = 
  f ...

should generate the same pattern matching code.

--Sigbjorn

Reply via email to