spotify-adblock
spotify-adblock copied to clipboard
Compile regex when reading the config file
Hello and thanks for the project! I was looking at the code and saw a TODO about compiling the regex once. So I fixed it. Now it is being compiled once when reading the toml file. Feel free to edit or close this request.
P.S. I'm very new to rust please recheck my code!
Thanks for having a go at that todo. Using a second struct doesn't seem very elegant though and names like ConfigRaw
and config_fixed
aren't very descriptive. The code that creates the Regex
s is also duplicated and should probably be in its own function if you were to do it like that.
The cleanest solution might be to just use serde_regex
and parse the config file to Regex
directly. I'm hesitant to add a new dependency though, especially one of which I'm not sure if it is actively maintained. I'll leave this open for now and see if I or anyone else can come up with a better solution.