text 0.11.1.0 → 0.11.1.1
raw patch · 3 files changed
+35/−4 lines, 3 filesdep ~basedep ~bytestring
Dependency ranges changed: base, bytestring
Files
- Data/Text/Lazy/Builder/RealFloat/Functions.hs +25/−0
- tests/benchmarks/src/Data/Text/Benchmarks/Equality.hs +8/−3
- text.cabal +2/−1
+ Data/Text/Lazy/Builder/RealFloat/Functions.hs view
@@ -0,0 +1,25 @@+-- |+-- Module: Data.Text.Lazy.Builder.RealFloat.Functions+-- Copyright: (c) The University of Glasgow 1994-2002+-- License: see libraries/base/LICENSE++module Data.Text.Lazy.Builder.RealFloat.Functions+ (+ roundTo+ ) where++roundTo :: Int -> [Int] -> (Int,[Int])+roundTo d is =+ case f d is of+ x@(0,_) -> x+ (1,xs) -> (1, 1:xs)+ _ -> error "roundTo: bad Value"+ where+ f n [] = (0, replicate n 0)+ f 0 (x:_) = (if x >= 5 then 1 else 0, [])+ f n (i:xs)+ | i' == 10 = (1,0:ds)+ | otherwise = (0,i':ds)+ where+ (c,ds) = f (n-1) xs+ i' = c + i
tests/benchmarks/src/Data/Text/Benchmarks/Equality.hs view
@@ -17,14 +17,19 @@ benchmark :: FilePath -> IO Benchmark benchmark fp = do b <- B.readFile fp- bl <- BL.readFile fp+ bl1 <- BL.readFile fp+ -- A lazy bytestring is a list of chunks. When we do not explicitly create two+ -- different lazy bytestrings at a different address, the bytestring library+ -- will compare the chunk addresses instead of the chunk contents. This is why+ -- we read the lazy bytestring twice here.+ bl2 <- BL.readFile fp l <- readFile fp let t = T.decodeUtf8 b- tl = TL.decodeUtf8 bl+ tl = TL.decodeUtf8 bl1 return $ bgroup "Equality" [ bench "Text" $ whnf (== T.init t `T.snoc` '\xfffd') t , bench "LazyText" $ whnf (== TL.init tl `TL.snoc` '\xfffd') tl , bench "ByteString" $ whnf (== B.init b `B.snoc` '\xfffd') b- , bench "LazyByteString" $ whnf (== BL.init bl `BL.snoc` '\xfffd') bl+ , bench "LazyByteString" $ whnf (== BL.init bl2 `BL.snoc` '\xfffd') bl1 , bench "String" $ whnf (== init l ++ "\xfffd") l ]
text.cabal view
@@ -1,5 +1,5 @@ name: text-version: 0.11.1.0+version: 0.11.1.1 homepage: https://bitbucket.org/bos/text bug-reports: https://bitbucket.org/bos/text/issues synopsis: An efficient packed Unicode text type.@@ -92,6 +92,7 @@ Data.Text.Fusion.Size Data.Text.IO.Internal Data.Text.Lazy.Builder.Functions+ Data.Text.Lazy.Builder.RealFloat.Functions Data.Text.Lazy.Encoding.Fusion Data.Text.Lazy.Fusion Data.Text.Lazy.Search