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

Allow changing a DFA's prefilter after it's already been created #1225

Open
ideka opened this issue Sep 17, 2024 · 1 comment
Open

Allow changing a DFA's prefilter after it's already been created #1225

ideka opened this issue Sep 17, 2024 · 1 comment

Comments

@ideka
Copy link

ideka commented Sep 17, 2024

I already added it to my fork but I guess I'd rather discuss it before submitting a PR.

In my use case prefilters are simple and speed up a search by an order of magnitude, but I'm serializing and deserializing DFA's with ::from_bytes, which doesn't preserve prefilters. For this reason I save the prefilter separately and need this function to readd it when deserializing, after the DFA has been built with ::from_bytes.

If changing a DFA at all after it's been built is really undesirable (is it?), another alternative would be to have ::from_bytes_with_prefilter function variants which would serve the same purpose and cover the only thing (as far as I know) that would otherwise be lost in DFA (de)serialization.

@BurntSushi
Copy link
Member

Yeah, I wish serialization would just handle prefilters automatically, but sadly that is a huge pile of work with far-reaching consequences.

I'm okay with a method that mutates a DFA in place to add a prefilter. This seems simplest to me since otherwise you'd need multiple constructors that add a prefilter (one for checked and one for unchecked, for example).

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

No branches or pull requests

2 participants