filepath-bytestring is a drop-in replacement for the standard haskell filepath library, that operates on RawFilePath rather than FilePath.
The benefit, of course, is speed. "foo" </> "bar"
is around 25% faster
with the new library. dropTrailingPathSeparator
is 120% faster. But the real speed benefits probably come when a program
is able to input filepaths as ByteStrings, manipulate them, and operate
on the files, all without using String.
It's extensively tested, not only does it run all the same doctests that the filepath library does, but each function is quickchecked to behave the same as the equivilant function from filepath.
While I implemented almost everything, I did leave
off some functions that operate on PATH, which seem unlikely to be useful,
and the complicated normalise
and stuff that uses it.
This work was sponsored by Jake Vosloo on Patron.
Using this library in git-annex, I saw a real-world speedup of 30% in
git annex find
. That command has to read a list of files fromgit ls-files
, and read all their symlinks, and check if the symlinks are broken or not. So there's a fair amount of IO, but FilePath overhead was still significant and worth eliminating.