Skip to content

Commit 622bff3

Browse files
author
Yves Orton
committed
simplify code - dont use to_string() where it is not needed
also add comment about why we sort the modifiers
1 parent 70ee357 commit 622bff3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/elixir/lib/regex.ex

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,12 @@ defmodule Regex do
476476
end
477477
end
478478

479-
disabled = List.to_string([?i, ?m, ?s, ?x] -- modifiers)
479+
disabled = [?i, ?m, ?s, ?x] -- modifiers
480480

481-
disabled = if disabled != "", do: "-#{disabled}", else: ""
481+
disabled = if disabled != [], do: "-#{disabled}", else: ""
482482

483-
modifiers =
484-
Enum.sort(modifiers)
485-
|> List.to_string()
483+
# Future proof option ordering consistency by sorting
484+
modifiers = Enum.sort(modifiers)
486485

487486
nl = if Enum.member?(regex_opts, :extended), do: "\n", else: ""
488487

0 commit comments

Comments
 (0)