TLDR;
Memoize (bind to a variable) the result of `Regex.compile!/2` on OTP 28 so
that it is only compiled once.
Background
Since in OTP 28 it's not possible to unquote a regex (~r/..../) into code,
the implementation of sigil_r on OTP 28 has to compile the regex at
runtime. In code which iterates over text using regex (for example Unicode
break algorithm, Unicode transforms and so on) this could lead to a
performance penalty.
Proposal
Bind the result of Regex.compile!/2 to a variable called something like
`__regex_#{hash_of_regex_string}` if its successful. If the variable is
bound, use it directly without compilation. Do performance testing to
confirm that there is benefit to memoizing.
I am fine to do this work if the proposal has merit.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/elixir-lang-core/afa20f7d-372c-4307-9884-7a1a931a927cn%40googlegroups.com.