BurntSushi/aho-corasick

Removing unused/redundant code

petar-dambovaliev opened this issue · 2 comments

Hey there, i have noticed that some struct fields aren't used.
For example, https://github.com/BurntSushi/aho-corasick/blob/master/src/ahocorasick.rs#L1222
And some small things that could be simplified https://github.com/BurntSushi/aho-corasick/blob/master/src/automaton.rs#L192

Both ends of that condition are calling the same method.
self.prefilter() already returns an option and the method could be a 1 liner passing the result of self.prefilter().
If changes like that are significant enough, i will make a PR and give my 2 cents.

The last_match_end piece does indeed look like it could be removed. Looks like a copy & paste error.

But the prefilter code is as intended. See this comment right below it for example:

// It's important for this to always be inlined. Namely, its only caller
// is standard_find_at, and the inlining should remove the case analysis
// for prefilter scanning when there is no prefilter available.

Probably there should be more comments calling this out, because it does indeed look weird. But the idea is to specialize each call with a specific value so that certain case analyses get removed from the hot loop.

The last_match_end piece does indeed look like it could be removed. Looks like a copy & paste error.

But the prefilter code is as intended. See this comment right below it for example:

// It's important for this to always be inlined. Namely, its only caller
// is standard_find_at, and the inlining should remove the case analysis
// for prefilter scanning when there is no prefilter available.

Probably there should be more comments calling this out, because it does indeed look weird. But the idea is to specialize each call with a specific value so that certain case analyses get removed from the hot loop.

I will have a closer look over the weekend and try to find more zebras.