bytestring icon indicating copy to clipboard operation
bytestring copied to clipboard

Add Data.ByteString.Char8.to{Low,Upp}er

Open Bodigrim opened this issue 3 years ago • 0 comments

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.

Bodigrim avatar Aug 01 '22 22:08 Bodigrim