> and the latter may have runtime impact.
Definitely a concern for the "simple" case of a use-once regex. I was thinking of something like (pseudo code)
var = :erlang.iolist_to_binary(["__regex_",:erlang.integer_to_list(abs(:erlang.monotonic_time(:nanosecond)))])
quote do
var = if var, do: var, else: Regex.compile!(binary_or_tuple, options)
end
Too much risk of performance impact? I think the BEAM optimises out the binding in positive cases like this?
> Instead, we are discussing adding the optimization we did before directly to Erlang/OTP
Yep, I'm anxiously awaiting a good outcome from that conversation :-) Thanks for encouraging the OTP team on this.