Skip to content

Commit 0fa06a2

Browse files
author
José Valim
committed
Precompile groups regex
1 parent e208237 commit 0fa06a2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/elixir/lib/regex.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,12 @@ defmodule Regex do
327327
end
328328
end
329329

330+
{ :ok, pattern } = :re.compile(%B"\(\?<(?<G>[^>]*)>")
331+
@groups_pattern pattern
332+
330333
defp parse_groups(source) do
331334
options = [:global, {:capture, ['G'], :binary}]
332-
{:ok, pattern} = :re.compile(%B"\(\?<(?<G>[^>]*)>")
333-
case :re.run(source, pattern, options) do
335+
case :re.run(source, @groups_pattern, options) do
334336
:nomatch -> []
335337
{ :match, results } ->
336338
lc [group] inlist results, do: binary_to_atom(group)

0 commit comments

Comments
 (0)