Adding the following rewrite rule makes the "case-insensitve"
benchmark as fast as the "no-class" benchmark:

{-# RULES
  "mk/ByteString" forall (bs :: B.ByteString). mk bs = CI bs (foldCaseBS bs)
  #-}

foldCaseBS :: B.ByteString -> B.ByteString
foldCaseBS bs = B.map toLower8' bs
    where
      toLower8' :: Word8 -> Word8
      toLower8' w
          |  65  <= w && w <=  90 ||
             192 <= w && w <= 214 ||
             216 <= w && w <= 222 = w + 32
          | otherwise             = w

Strangely, using the existing foldCase method or the toLower8 function
makes the code slow again.

I committed[1] this to the "hp" branch.

Bas

[1] 
https://github.com/basvandijk/case-insensitive/commit/158e0f02a7832ebe7e46f5784f87a0923e8ea3e6

_______________________________________________
Haskell-platform mailing list
Haskell-platform@projects.haskell.org
http://projects.haskell.org/cgi-bin/mailman/listinfo/haskell-platform

Reply via email to