summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikitaVolkov <>2017-03-20 22:29:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-03-20 22:29:00 (GMT)
commitdee4b3d2bcb7b2a0898f20af8144c003e8a5ff7b (patch)
tree4821cfb6d473ab9a03faa5da82e3919ad621ed0f
parentdca534dc93df7edd61549a5823b841ed97feffcd (diff)
version 0.4.30.4.3
-rw-r--r--benchmarks/Main.hs11
-rw-r--r--bytestring-strict-builder.cabal8
-rw-r--r--library/ByteString/StrictBuilder.hs8
3 files changed, 21 insertions, 6 deletions
diff --git a/benchmarks/Main.hs b/benchmarks/Main.hs
index 28d7549..ae9c855 100644
--- a/benchmarks/Main.hs
+++ b/benchmarks/Main.hs
@@ -1,12 +1,12 @@
module Main where
-import Prelude
+import Prelude hiding (concat)
import Criterion.Main
import ByteString.StrictBuilder
main =
- defaultMain [leftAppends, rightAppends]
+ defaultMain [leftAppends, rightAppends, concat]
leftAppends :: Benchmark
leftAppends =
@@ -27,3 +27,10 @@ rightAppends =
where
builder =
foldr (<>) mempty bytesList
+
+concat :: Benchmark
+concat =
+ bench "concat" $ whnf action $! replicate 10000 $ bytes "abc"
+ where
+ action bytesList =
+ builderBytes (mconcat bytesList)
diff --git a/bytestring-strict-builder.cabal b/bytestring-strict-builder.cabal
index 135c24b..0734a68 100644
--- a/bytestring-strict-builder.cabal
+++ b/bytestring-strict-builder.cabal
@@ -1,7 +1,7 @@
name:
bytestring-strict-builder
version:
- 0.4.2
+ 0.4.3
category:
Text, ByteString, Builders, Serialization
synopsis:
@@ -9,9 +9,9 @@ synopsis:
description:
According to
<https://github.com/nikita-volkov/bytestring-builders-benchmark the competition benchmarks>,
- this library provides the fastest builder of strict bytestrings.
+ this library provides on average the fastest builder of strict bytestrings.
.
- Practical benchmarks have proven it to be highly performant aswell.
+ Practical benchmarks have proven it to be highly performant as well.
The encoders from the \"postgresql-binary\" library have shown
a stable performance improvement by factors of up to 10 after the migration
from the standard builder to \"bytestring-strict-builder\".
@@ -56,7 +56,7 @@ library
ByteString.StrictBuilder.UTF8
build-depends:
semigroups >= 0.18 && < 0.19,
- bytestring >= 0.10 && < 0.11,
+ bytestring >= 0.10.2 && < 0.11,
base-prelude >= 1.2 && < 2,
base >= 4.6 && < 5
diff --git a/library/ByteString/StrictBuilder.hs b/library/ByteString/StrictBuilder.hs
index 22af68e..200f2f3 100644
--- a/library/ByteString/StrictBuilder.hs
+++ b/library/ByteString/StrictBuilder.hs
@@ -40,6 +40,14 @@ instance Monoid Builder where
{-# INLINE mappend #-}
mappend (Builder leftSize leftPopulation) (Builder rightSize rightPopulation) =
Builder (leftSize + rightSize) (leftPopulation <> rightPopulation)
+ {-# INLINE mconcat #-}
+ mconcat builders =
+ Builder size population
+ where
+ size =
+ getSum (foldMap (\(Builder x _) -> Sum x) builders)
+ population =
+ foldMap (\(Builder _ x) -> x) builders
instance Semigroup Builder