Git Product home page Git Product logo

Comments (2)

BurntSushi avatar BurntSushi commented on September 29, 2024

IMO, if you can use aho-corasick and you're otherwise not already using the regex crate, then you probably should use aho-corasick. Reasons:

  1. A lot less code to build and rely upon. aho-corasick is just matching literals. regex has a lot of code for handing the much more general case.
  2. aho-corasick is going to build its searcher much more quickly than regex. I hope to fix most of this in the not so distant future, but the regex crate is always going to have some kind of additional overhead. Today, it's quite a bit more than it needs to be.

Would that be a certain number inputs or would this algorithm always be preferable?

If you just have a regex like foo|bar|...|quux, then the regex crate will likely just use this crate.

But, you should always benchmark your specific use case. If you do have a case where regex is faster than aho-corasick, that would be very interesting and I should like to hear about it.

from aho-corasick.

ritchie46 avatar ritchie46 commented on September 29, 2024

If you do have a case where regex is faster than aho-corasick, that would be very interesting and I should like to hear about it.

Promised. Will do! Thanks for the explanation.

from aho-corasick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.