ErythroGuild / irene

<Erythro>'s server admin bot.
Mozilla Public License 2.0
0 stars 0 forks source link

Optimize regexes #397

Open Ernest314 opened 1 year ago

Ernest314 commented 1 year ago

Current implementations are often very naive and unoptimized.

See: https://blog.stevenlevithan.com/archives/greedy-lazy-performance

Ernest314 commented 1 year ago

This includes not using the RegexOptions.Compiled option.

Takes an order of magnitude more time to start up, and then is about 30% faster. This should only ever be used when they're only instantiated once (i.e. static Regex objects), and the regex is also fairly complex. See: https://blog.codinghorror.com/to-compile-or-not-to-compile/

Ernest314 commented 1 year ago

reading resources (taken from #143):

Ernest314 commented 1 year ago

Also see #389