Merge pull request #1905 from josephcsible/skiprepeating

Make skipRepeating lazier and faster
This commit is contained in:
Vidar Holen 2020-04-12 15:21:39 -07:00 committed by GitHub
commit 58d3e50f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -957,9 +957,9 @@ checkCatastrophicRm = CommandCheck (Basename "rm") $ \t ->
f _ = return "" f _ = return ""
stripTrailing c = reverse . dropWhile (== c) . reverse stripTrailing c = reverse . dropWhile (== c) . reverse
skipRepeating c (a:b:rest) | a == b && b == c = skipRepeating c (b:rest) skipRepeating c = foldr go []
skipRepeating c (a:r) = a:skipRepeating c r where
skipRepeating _ [] = [] go a r = a : case r of b:rest | b == c && a == b -> rest; _ -> r
paths = [ paths = [
"", "/bin", "/etc", "/home", "/mnt", "/usr", "/usr/share", "/usr/local", "", "/bin", "/etc", "/home", "/mnt", "/usr", "/usr/share", "/usr/local",