
28 Jan
2013
28 Jan
'13
5:47 a.m.
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/158e0f02a7832ebe7e46f5...