filepath-bytestring 1.4.2.1.7 → 1.4.2.1.8
raw patch · 4 files changed
+55/−15 lines, 4 filesdep +criteriondep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: criterion
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG +13/−0
- System/FilePath/Internal.hs +6/−13
- benchmark/benchmark.hs +21/−0
- filepath-bytestring.cabal +15/−2
CHANGELOG view
@@ -1,3 +1,16 @@+filepath-bytestring (1.4.2.1.8) unstable; urgency=medium++ * Faster implementations of encodeFilePath and decodeFilePath.+ They are approximately 2x and 3x as fast, respectively.+ * encodeFilePath and decodeFilePath used to truncate at the first+ NUL. The new implementations do not do this. Since unix filepaths+ cannot contain NUL, this behavior change is can't cause any problems,+ unless the functions are used for values that are not actually+ valid filepaths.+ * Support cabal bench to benchmark the library.++ -- Joey Hess <id@joeyh.name> Wed, 11 Aug 2021 12:17:15 -0400+ filepath-bytestring (1.4.2.1.7) unstable; urgency=medium * Relax QuickCheck bounds to allow 2.14.
System/FilePath/Internal.hs view
@@ -136,6 +136,7 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8+import Data.ByteString.Unsafe (unsafePackMallocCStringLen) import Data.Char(ord, chr, toUpper, toLower, isAsciiLower, isAsciiUpper) import Data.Maybe(isJust) import Data.Word(Word8)@@ -174,13 +175,9 @@ #ifdef mingw32_HOST_OS encodeFilePath = UTF8.fromString #else-encodeFilePath = B.pack . map (fromIntegral . fromEnum) . encodeFilePath'--{-# NOINLINE encodeFilePath' #-}-encodeFilePath' :: FilePath -> String-encodeFilePath' f = unsafePerformIO $ do+encodeFilePath f = unsafePerformIO $ do enc <- Encoding.getFileSystemEncoding- GHC.withCString enc f (GHC.peekCString Encoding.char8)+ GHC.newCStringLen enc f >>= unsafePackMallocCStringLen #endif -- | Convert from RawFilePath to FilePath@@ -193,15 +190,11 @@ #ifdef mingw32_HOST_OS decodeFilePath = UTF8.toString #else-decodeFilePath = decodeFilePath' . map (toEnum . fromIntegral) . B.unpack--{-# NOINLINE decodeFilePath' #-}-decodeFilePath' :: String -> FilePath-decodeFilePath' s = unsafePerformIO $ do+{-# NOINLINE decodeFilePath #-}+decodeFilePath f = unsafePerformIO $ do enc <- Encoding.getFileSystemEncoding- GHC.withCString Encoding.char8 s (GHC.peekCString enc)+ B.useAsCStringLen f (GHC.peekCStringLen enc) #endif- --------------------------------------------------------------------- -- Platform Abstraction Methods (private)
+ benchmark/benchmark.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE OverloadedStrings #-}++import qualified System.FilePath as FilePath+import qualified System.FilePath.ByteString as RawFilePath+import Criterion.Main++main :: IO ()+main = defaultMain+ [ bgroup "combine"+ [ bench "FilePath" $ nf (FilePath.combine "foo") "bar"+ , bench "RawFilePath" $ nf (RawFilePath.combine "foo") "bar"+ ]+ , bgroup "dropTrailingPathSeparator"+ [ bench "FilePath" $ nf FilePath.dropTrailingPathSeparator "foo/"+ , bench "RawFilePath" $ nf RawFilePath.dropTrailingPathSeparator "foo/"+ ]+ , bgroup "FilePath conversion"+ [ bench "encode" $ nf RawFilePath.encodeFilePath "foobar.baz"+ , bench "decode" $ nf RawFilePath.decodeFilePath "foobar.baz"+ ]+ ]
filepath-bytestring.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.18 name: filepath-bytestring-version: 1.4.2.1.7+version: 1.4.2.1.8 -- NOTE: Don't forget to update CHANGELOG and the filepath dependency below license: BSD3 license-file: LICENSE author: Neil Mitchell <ndmitchell@gmail.com> maintainer: Joey Hess <id@joeyh.name> copyright: Neil Mitchell 2005-2019- Joey Hess 2019+ Joey Hess 2019-2021 category: System build-type: Simple synopsis: Library for manipulating RawFilePaths in a cross platform way.@@ -75,4 +75,17 @@ QuickCheck >= 2.7 && < 2.15, -- Versions of filepath that are equvilant to this -- library, for quickcheck equivilance tests.+ filepath >= 1.4.2 && <= 1.4.2.1++benchmark filepath-bench+ type: exitcode-stdio-1.0+ default-language: Haskell2010+ main-is: benchmark.hs+ ghc-options: -O2 -Wall -fno-warn-tabs+ hs-source-dirs: benchmark+ build-depends: + base,+ criterion,+ filepath-bytestring,+ -- Version of filepath to benchmark against filepath >= 1.4.2 && <= 1.4.2.1