bytestring
bytestring copied to clipboard
Add Data.ByteString.Char8.to{Low,Upp}er
Case conversions can benefit from low-level tricks. While Data.ByteString.Char8.map Data.Char.toLower converts byte by byte, one can actually read 8 bytes at once as Word64 (or even more, when vectorised instructions are available), build a mask checking which bytes are uppercase (this can be done in a single instruction), then shift the mask by 5 and add to the original Word64.