Closed tuube closed 3 years ago
Hi, thanks for your contribution! There haven't been commits here in a while and it looks like my CI is a bit broken :sweat_smile: but I'm happy with this PR so I'll merge it anyway and get a release out once I've fixed the other stuff later today
Thanks again, this is now available in version 2.1.1 :)
No problem, I'm glad to help 😄
The current usage of Regex is very slow when used in a loop. Regex library docs tell us that compiling regex is quite expensive and should not be done in a loop. I fixed the issue by using
lazy_static
to create the regex instances, as the docs recommend.I measured the time of 1000 runs of
DateTuple::from_str()
with both implementations, and the one withlazy_static
wins clearly:Also fixed typo in a comment.