@@ -1791,19 +1791,15 @@ data SplitOnState fs s a b w rb rh ck =
1791 GO_START
1791 GO_START
1792 | GO_EMPTY_PAT s
1792 | GO_EMPTY_PAT s
1793 | GO_EMPTY_PAT_WITH s a
1793 | GO_EMPTY_PAT_WITH s a
1794− -- | GO_SINGLE_PAT_BEGIN s a -- Only for splitSuffixOn
1795 | GO_SINGLE_PAT_NEXT !fs s a
1794 | GO_SINGLE_PAT_NEXT !fs s a
1796 | GO_SINGLE_PAT_WITH !fs s a a
1795 | GO_SINGLE_PAT_WITH !fs s a a
1797 | GO_SHORT_PAT_ACCUM Int s !w
1796 | GO_SHORT_PAT_ACCUM Int s !w
1798 | GO_SHORT_PAT_NEXT !fs s !w
1797 | GO_SHORT_PAT_NEXT !fs s !w
1799 | GO_SHORT_PAT_NEXT_WITH !fs s a !w
1798 | GO_SHORT_PAT_NEXT_WITH !fs s a !w
1800 | GO_SHORT_PAT_DRAIN Int !fs !w
1799 | GO_SHORT_PAT_DRAIN Int !fs !w
1801− -- | GO_SHORT_PAT_YIELD_SEP Int !fs s w -- Only for splitSuffixOn.
1802 | GO_KARP_RABIN_ACCUM Int s rb !rh
1800 | GO_KARP_RABIN_ACCUM Int s rb !rh
1803 | GO_KARP_RABIN_NEXT !fs s rb !rh !ck
1801 | GO_KARP_RABIN_NEXT !fs s rb !rh !ck
1804− | GO_KARP_RABIN_NEXT_WITH !fs s a rb !rh !ck
1805 | GO_KARP_RABIN_DRAIN Int !fs rb !rh
1802 | GO_KARP_RABIN_DRAIN Int !fs rb !rh
1806− -- | GO_KARP_RABIN_YIELD_SEP Int !fs s rb rh -- Only for splitSuffixOn.
1807 | GO_YIELD b (SplitOnState fs s a b w rb rh ck)
1803 | GO_YIELD b (SplitOnState fs s a b w rb rh ck)
1808 | GO_DONE
1804 | GO_DONE
@@ -2010,32 +2006,27 @@ splitOn patArr (Fold fstep initial done) (Stream step state) =
2011 r <- done ini
2007 r <- done ini
2012 return $ Skip $ GO_YIELD r GO_DONE
2008 return $ Skip $ GO_YIELD r GO_DONE
2013− -- XXX Theoretically this code can do 4 times faster if GHC generates
2009+ stepOuter gst (GO_KARP_RABIN_NEXT fs0 st0 rb rh0 cksum0) =
2014− -- optimal code. If we use just "(cksum1 == patHash)" condition it goes 4x
2010+ go SPEC fs0 st0 rh0 cksum0
2015− -- faster, as soon as we add the "RB.unsafeEqArray rb v" condition the
2011+
2016− -- generated code changes drastically and becomes 4x slower. Need to
2012+ where
2017− -- investigate what is going on with GHC.
2013+
2018− stepOuter _ (GO_KARP_RABIN_NEXT_WITH fs s x rb rh cksum) = do
2014+ go !_ !fs !st !rh !cksum = do
2015+ res <- step (adaptState gst) st
2019− old <- liftIO $ peek rh
2018+ old <- liftIO $ peek rh
2020− let cksum1 = deltaCksum cksum old x
2019+ let cksum1 = deltaCksum cksum old x
2021− fres <- fstep fs old
2020+ fres <- fstep fs old
2022− if (cksum1 == patHash)
2021+ if (cksum1 == patHash)
2023− then do
2022+ then do
2024− r <- done fres
2023+ r <- done fres
2025− -- XXX It does not matter whether we give rh or rh1
2026− -- here. We restart anyway.
2027− return $ Skip $ GO_YIELD r $ GO_KARP_RABIN_ACCUM 0 s rb rh
2024+ return $ Skip $ GO_YIELD r $ GO_KARP_RABIN_ACCUM 0 s rb rh
2028− else do
2025+ else do
2029− rh1 <- liftIO (RB.unsafeInsert rb rh x)
2026+ rh1 <- liftIO (RB.unsafeInsert rb rh x)
2030− return $ Skip $ GO_KARP_RABIN_NEXT fres s rb rh1 cksum1
2027+ go SPEC fres s rh1 cksum1
2031− stepOuter gst (GO_KARP_RABIN_NEXT fs st rb rh cksum) = do
2028+ Skip s -> go SPEC fs s rh cksum
2032− res <- step (adaptState gst) st
2036− Yield x s -> GO_KARP_RABIN_NEXT_WITH fs s x rb rh cksum
2037− Skip s -> GO_KARP_RABIN_NEXT fs s rb rh cksum
2038− Stop -> GO_KARP_RABIN_DRAIN patLen fs rb rh
2029+ Stop -> return $ Skip $ GO_KARP_RABIN_DRAIN patLen fs rb rh
2039 stepOuter _ (GO_KARP_RABIN_DRAIN 0 fs _ _) = do
2030 stepOuter _ (GO_KARP_RABIN_DRAIN 0 fs _ _) = do
2040 r <- done fs
2031 r <- done fs
2041 return $ Skip $ GO_YIELD r GO_DONE
2032 return $ Skip $ GO_YIELD r GO_DONE