Skip to content

Commit 59c3480

Browse files
committed
Text: flip isSubsequenceOf
Previous argument order was alike `lookup` argument order mistake, when key cached (compiler saturates function) across DBs. Efficient use of the function is to all it once (per pattern) on the whole contents. So the contents should be cached first, and the search patterns are switchable.
1 parent d2425fb commit 59c3480

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Data/Text.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,20 +1879,20 @@ isInfixOf needle haystack
18791879
{-# INLINE [1] isInfixOf #-}
18801880

18811881
-- | The 'isSubsequenceOf' function takes two 'Text's and returns
1882-
-- 'True' iff the first is a subsequence of a second.
1883-
-- (characters of the first argument appear in same sequential order in
1884-
-- the second, to say if first argument that can be derived by deleting some
1885-
-- or no elements from the second).
1882+
-- 'True' iff the second is a subsequence of the first.
1883+
-- (characters of the second argument appear in same sequential order in
1884+
-- the first, to say if second argument can be derived by deleting some
1885+
-- or no elements from the first).
18861886
isSubsequenceOf :: Text -> Text -> Bool
1887-
isSubsequenceOf sf tf
1887+
isSubsequenceOf tf sf
18881888
| length sf > length tf = False
1889-
| otherwise = subseqOf sf tf
1889+
| otherwise = subseqOf tf sf
18901890
where
1891-
subseqOf s t
1891+
subseqOf t s
18921892
| null s = True
18931893
| null t = False
1894-
| unsafeHead s == unsafeHead t = subseqOf (unsafeTail s) (unsafeTail t)
1895-
| otherwise = subseqOf s $ unsafeTail t
1894+
| unsafeHead s == unsafeHead t = subseqOf (unsafeTail t) (unsafeTail s)
1895+
| otherwise = subseqOf (unsafeTail t) s
18961896

18971897
-------------------------------------------------------------------------------
18981898
-- * View patterns

0 commit comments

Comments
 (0)