Skip to content

Conversation

meh
Copy link
Contributor

@meh meh commented May 30, 2013

This needs more tests, give your best try at breaking it.

@@ -291,6 +291,11 @@ defmodule Regex do
:re.replace(string, compiled, replacement, opts)
end

@spec escape(String.t) :: String.t
def escape(string) do
Regex.replace(%r/[.^$*+?()[{\\|]/, string, "\\\\&")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. use local call replace
  2. don't use %r. It calls to Regex.compile! and Regex is not compiled. It confuses the ParallelCompiler. You should only use local calls inside the module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

josevalim pushed a commit that referenced this pull request May 31, 2013
@josevalim josevalim merged commit ac0ac7f into elixir-lang:master May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants