on master help sign in
Change builder benchmarks to use foldr

--HG-- extra : convert_revision : abeed1a78b4edf5a0c333c2adb994641bc772e95

commit2db80841c878227145ea707dd7feac2a1df36e40 authorJohan Tibell <johan.tibell@gmail.com> dateFri 14 May 2010, 18:06 (16 years ago) parentba12205
1 file changed+8−8
tests/Benchmarks.hs+8−8
tests/Benchmarks.hs+8−8
@@ -419,11 +419,11 @@ chunksOf k = go
419419 | otherwise -> a : go b
420420
421421mappendNChar :: Char -> Int -> TB.Builder
422−mappendNChar c n = go 0 mempty
422+mappendNChar c n = go 0
423423 where
424− go i !acc
425− | i < n = go (i+1) (acc `mappend` TB.singleton c)
426− | otherwise = acc
424+ go i
425+ | i < n = TB.singleton c `mappend` go (i+1)
426+ | otherwise = mempty
427427
428428-- Gives more opportunity for inlining and elimination of unnecesary
429429-- bounds checks.
@@ -434,8 +434,8 @@ mappend8Char c = TB.singleton c `mappend` TB.singleton c `mappend`
434434 TB.singleton c `mappend` TB.singleton c
435435
436436mappendNText :: TS.Text -> Int -> TB.Builder
437−mappendNText t n = go 0 mempty
437+mappendNText t n = go 0
438438 where
439− go i !acc
440− | i < n = go (i+1) (acc `mappend` TB.fromText t)
441− | otherwise = acc
439+ go i
440+ | i < n = TB.fromText t `mappend` go (i+1)
441+ | otherwise = mempty