spotify-adblock icon indicating copy to clipboard operation
spotify-adblock copied to clipboard

Compile regex when reading the config file

Open HirbodBehnam opened this issue 3 years ago • 1 comments

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!

HirbodBehnam avatar May 26 '21 10:05 HirbodBehnam

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 Regexs 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.

abba23 avatar May 26 '21 15:05 abba23