Skip to content

Commit 2b352e7

Browse files
committed
Cleaned up README.md a bit
1 parent e7e5d50 commit 2b352e7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Diff for: README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
I'm trying to do reasonably fast character escaping in Haskell (that is, within a few factors of C). Using [plain `ByteString` manipulation][1], my Haskell implementation is 125 times slower than my C implementation. Then I tried to use [blaze-builder][2]. That was even slower.
1+
I'm trying to do reasonably fast character escaping in Haskell (that is, within a few factors of C). Using [plain ByteString manipulation][1], my Haskell implementation is 125 times slower than my C implementation. Then I tried to use [blaze-builder][2]. That was even slower.
22

3-
I eventually managed to get it to about 1.5 times slower than the C version (very good!). However, it uses a lot of ugly buffer manipulation, and the performance boost is very sensitive to what gets inlined and what doesn't.
4-
5-
The key function is this:
3+
I eventually managed to get it to about 1.5 times slower than the C version (very good!). The key function is this:
64

75
concatMapWrite :: (Word8 -> Write) -> ByteString -> ByteString
86

9-
It is like [concatMap from Data.ByteString][3]. However, instead of the callback returning a `ByteString`, it returns a [Write][4] object (defined in the [blaze-builder][5] package), which is used to write the data directly into a buffer.
7+
It is like [concatMap from Data.ByteString][3]. However, instead of the callback returning a [ByteString][6], it returns a [Write][4] which is used to write the data directly into a buffer.
8+
9+
However, there are two problems:
10+
11+
* It uses a lot of ugly buffer manipulation,
12+
13+
* The performance boost is very sensitive to what gets inlined and what doesn't.
1014

1115
Is there a better way to translate a sequence of bytes in Haskell than this?
1216

@@ -19,3 +23,5 @@ Is there a better way to translate a sequence of bytes in Haskell than this?
1923
[4]: http://hackage.haskell.org/packages/archive/blaze-builder/latest/doc/html/Blaze-ByteString-Builder.html#t:Write
2024

2125
[5]: http://hackage.haskell.org/package/blaze-builder
26+
27+
[6]: http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#t:ByteString

0 commit comments

Comments
 (0)