git.iko.soy/typeable/html-parse
on master help sign in
Use inlined form of attoparsec's takeWhile

before: ``` -rw-r--r-- 1 ben ben 1.7M Apr 6 13:51 Text/HTML/Parser.o $ ./Benchmark "length/mine Text" +RTS -t -rticky benchmarking length/mine Text time 134.0 ms (129.2 ms .. 137.9 ms) 0.998 R² (0.996 R² .. 1.000 R²) mean 139.1 ms (136.1 ms .. 147.3 ms) std dev 7.026 ms (1.265 ms .. 10.44 ms) variance introduced by outliers: 11% (moderately inflated) <<ghc: 12390325864 bytes, 24154 GCs, 1496358/2401640 avg/max bytes residency (6 samples), 8M in use, 0.000 INIT (0.000 elapsed), 7.425 MUT (7.427 elapsed), 0.451 GC (0.450 elapsed) :ghc>> ``` after: ``` -rw-r--r-- 1 ben ben 1.9M Apr 6 13:52 Text/HTML/Parser.o $ ./Benchmark "length/mine Text" +RTS -t -rticky benchmarking length/mine Text time 47.21 ms (46.00 ms .. 48.44 ms) 0.997 R² (0.993 R² .. 1.000 R²) mean 47.59 ms (47.10 ms .. 48.67 ms) std dev 1.351 ms (387.4 μs .. 2.121 ms) <<ghc: 17403261432 bytes, 34152 GCs, 1496800/2403408 avg/max bytes residency (6 samples), 8M in use, 0.000 INIT (0.000 elapsed), 6.715 MUT (6.717 elapsed), 0.623 GC (0.621 elapsed) :ghc>> ```

commit3f61cb1cd4c69d9b28da0f66a5e70a5eede86f58 authorBen Gamari <ben@smart-cactus.org> dateWed 6 Apr 2016, 13:32 (11 years ago) parent9a0971f
1 file changed+4−1
Text/HTML/Parser.hs+4−1
Text/HTML/Parser.hs+4−1
@@ -17,7 +17,8 @@ import Data.Monoid
1717import Control.Monad (guard)
1818import Control.DeepSeq
1919
20−import Data.Attoparsec.Text
20+import Data.Attoparsec.Text hiding (takeWhile)
21+import qualified Data.Attoparsec.Text as A
2122import Data.Text (Text)
2223import qualified Data.Text as T
2324import Data.Text.Lazy.Builder (Builder)
@@ -42,6 +43,8 @@ data Token
4243 | Doctype !Text
4344 deriving (Show, Ord, Eq, Generic)
4445
46+takeWhile = A.takeWhile'
47+
4548data Attr = Attr !AttrName !AttrValue
4649 deriving (Show, Eq, Ord)
4750