• Andreas Klebinger's avatar
    Fix "build/elem" RULE. · f10d11fa
    Andreas Klebinger authored
    An redundant constraint prevented the rule from matching.
    
    Fixing this allows a call to elem on a known list to be translated
    into a series of equality checks, and eventually a simple case
    expression.
    
    Surprisingly this seems to regress elem for strings. To avoid
    this we now also allow foldrCString to inline and add an UTF8
    variant. This results in elem being compiled to a tight
    non-allocating loop over the primitive string literal which
    performs a linear search.
    
    In the process this commit adds UTF8 variants for some of the
    functions in GHC.CString. This is required to make this work for
    both ASCII and UTF8 strings.
    
    There are also small tweaks to the CString related rules.
    We now allow ourselfes the luxury to compare the folding function
    via eqExpr, which helps to ensure the rule fires before we inline
    foldrCString*. Together with a few changes to allow matching on both
    the UTF8 and ASCII variants of the CString functions.
    f10d11fa
Code owners : Herbert Valerio Riedel
Base.hs 51.7 KB