Skip to content

Commit

Permalink
Remove unneeded workarounds for xref warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fhunleth authored and michalmuskala committed Jul 26, 2024
1 parent 433f93d commit 9517f56
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
5 changes: 1 addition & 4 deletions lib/decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ defmodule Jason.Decoder do
if Code.ensure_loaded?(Decimal) do
defp float_decode_function(%{floats: :decimals}) do
fn string, token, skip ->
# silence xref warning
decimal = Decimal

try do
decimal.new(string)
Decimal.new(string)
rescue
Decimal.Error ->
token_error(token, skip)
Expand Down
4 changes: 1 addition & 3 deletions lib/encode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ defmodule Jason.Encode do

if Code.ensure_loaded?(Decimal) do
defp struct(value, _escape, _encode_map, Decimal) do
# silence the xref warning
decimal = Decimal
[?", decimal.to_string(value, :normal), ?"]
[?", Decimal.to_string(value, :normal), ?"]
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ end
if Code.ensure_loaded?(Decimal) do
defimpl Jason.Encoder, for: Decimal do
def encode(value, _opts) do
# silence the xref warning
decimal = Decimal
[?", decimal.to_string(value), ?"]
[?", Decimal.to_string(value), ?"]
end
end
end
Expand Down

0 comments on commit 9517f56

Please sign in to comment.