Skip to content

Would you accept a convenience function for replace_all that builds the AhoCorasick automaton for you? #152

Answered by BurntSushi
arifd asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reaching out. I did find your framing here a little confusing because AhoCorasick::replace_all only accepts one slice. But you mention two slices. After I read through your full post, I think I understand: you're talking about the original sequence of patterns (used to build AhoCorasick) and then the sequence of replacements for each pattern. But these are two entirely separate parts of the API.

Combining them into one API seems like bad juju to me, because it means you'll have to pay for AhoCorasick construction every single time you call it. Building a AhoCorasick can be somewhat expensive, so I'm not sure there's really enough benefit here to be worth that cost.

Moreover, I …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@BurntSushi
Comment options

@arifd
Comment options

@BurntSushi
Comment options

@arifd
Comment options

@BurntSushi
Comment options

Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants