Skip to content

Commit

Permalink
Optimize JSON sanitization step
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Sep 4, 2023
1 parent f1d4f70 commit b96d6cf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,19 @@ defmodule Sentry.Client do
end

defp sanitize_non_jsonable_value(value, json_library) when is_list(value) do
mapped =
Enum.map(value, fn value ->
{mapped, changed?} =
Enum.map_reduce(value, _changed? = false, fn value, changed? ->
case sanitize_non_jsonable_value(value, json_library) do
:unchanged -> value
{:changed, value} -> value
:unchanged -> {value, changed?}
{:changed, value} -> {value, true}
end
end)

{:changed, mapped}
if changed? do
{:changed, mapped}
else
:unchanged
end
end

defp sanitize_non_jsonable_value(value, json_library)
Expand Down

0 comments on commit b96d6cf

Please sign in to comment.