optimize truncateFilePath
Often the filepath will be all ascii, or mostly so, and this optimisation makes a file that has an ascii suffix of sufficient length be roundtrip converted between String and ByteString only once, rather than once per character. Sponsored-by: Graham Spencer
This commit is contained in:
parent
6211e2af4a
commit
f17ec601c4
4 changed files with 47 additions and 26 deletions
|
@ -112,8 +112,8 @@ relatedTemplate f
|
|||
{- Some filesystems like FAT have issues with filenames
|
||||
- ending in ".", so avoid truncating a filename to end
|
||||
- that way. -}
|
||||
toOsPath $ B.dropWhileEnd (== dot) $ toRawFilePath $
|
||||
truncateFilePath (len - templateAddedLength) (fromRawFilePath f)
|
||||
toOsPath $ B.dropWhileEnd (== dot) $
|
||||
truncateFilePath (len - templateAddedLength) f
|
||||
| otherwise = toOsPath f
|
||||
where
|
||||
len = B.length f
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue