Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large character classes combined with {m,n} is very slow and memory-hungry #14

Closed
jaspervdj opened this issue Nov 22, 2017 · 3 comments
Closed

Comments

@jaspervdj
Copy link

jaspervdj commented Nov 22, 2017

module Main where
import qualified Text.Regex.TDFA as Tdfa

main :: IO ()
main = do
    let pattern = "^[\x0020-\xD7FF]{1,255}$"
        input   = take 100 $ cycle "abcd"

        regex :: Tdfa.Regex
        regex = Tdfa.makeRegexOpts Tdfa.defaultCompOpt Tdfa.defaultExecOpt pattern

        matches :: [Tdfa.MatchArray]
        matches = Tdfa.match regex input

    print matches

This takes over 6 seconds on my machine and claims around 3GB(!) in memory. Removing the {m,n} part and using "^[\x0020-\xD7FF]+$" combined with an explicit length check (in Haskell) is a workaround.

@neongreen
Copy link
Collaborator

😔

I don't have time for maintaining this library, but patches are welcome.

@ChrisKuklewicz
Copy link
Owner

ChrisKuklewicz commented Mar 11, 2018 via email

@neongreen
Copy link
Collaborator

Moving over to haskell-hvr/regex-tdfa#3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants