Skip to content

Commit

Permalink
Remove code for 1.10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Nov 10, 2024
1 parent 9c63f4f commit 11410e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
6 changes: 2 additions & 4 deletions lib/aja.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ defmodule Aja do

:guard ->
quote do
# TODO simplify when stop supporting Elixir 1.10
:erlang.map_get(:__ord_map__, unquote(ord_map)) |> :erlang.map_size()
unquote(ord_map).__ord_map__ |> :erlang.map_size()
end
end
end
Expand Down Expand Up @@ -336,8 +335,7 @@ defmodule Aja do
quote do
:erlang.element(
1,
# TODO simplify when stop supporting Elixir 1.10
:erlang.map_get(:__vector__, unquote(vector))
unquote(vector).__vector__
)
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/ord_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ defmodule Aja.OrdMap do

@doc false
defguard is_dense(ord_map)
# TODO simplify when stop supporting Elixir 1.10
when :erlang.map_get(:__ord_map__, ord_map) |> map_size() ===
:erlang.map_get(:__ord_vector__, ord_map) |> RawVector.size()
when map_size(ord_map.__ord_map__) === RawVector.size(ord_map.__ord_vector__)

@doc """
Returns the number of keys in `ord_map`.
Expand Down
22 changes: 2 additions & 20 deletions lib/string.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,11 @@ defmodule Aja.String do
end

defp normalize(string, :ascii) do
for <<c <- nfkd_normalize(string)>>, c in 0..127, into: "", do: <<c>>
for <<c <- String.normalize(string, :nfkd)>>, c in 0..127, into: "", do: <<c>>
end

defp normalize(string, _mode) do
nfkc_normalize(string)
end

defp nfkc_normalize(string) do
# Note: same implementation as `String.normalize(string, :nfkc)` in Elixir 1.11
# TODO replace when removing support for 1.10
case :unicode.characters_to_nfkc_binary(string) do
normalized when is_binary(normalized) -> normalized
{:error, good, <<head, rest::binary>>} -> good <> <<head>> <> nfkc_normalize(rest)
end
end

defp nfkd_normalize(string) do
# Note: same implementation as `String.normalize(string, :nfkd)` in Elixir 1.11
# TODO replace when removing support for 1.10
case :unicode.characters_to_nfkd_binary(string) do
normalized when is_binary(normalized) -> normalized
{:error, good, <<head, rest::binary>>} -> good <> <<head>> <> nfkd_normalize(rest)
end
String.normalize(string, :nfkc)
end

defp try_replace(string, regex, new) do
Expand Down

0 comments on commit 11410e3

Please sign in to comment.