Skip to content

Commit

Permalink
topdown: Use json.Valid instead of util.UnmarshalJSON to avoid un…
Browse files Browse the repository at this point in the history
…necessary allocations. (open-policy-agent#4203)

Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
  • Loading branch information
kristiansvalland committed Jan 10, 2022
1 parent 4985e4b commit 8b33bca
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions topdown/encoding.go
Expand Up @@ -58,9 +58,7 @@ func builtinJSONIsValid(a ast.Value) (ast.Value, error) {
return nil, err
}

var x interface{}
err = util.UnmarshalJSON([]byte(str), &x)
return ast.Boolean(err == nil), nil
return ast.Boolean(json.Valid([]byte(str))), nil
}

func builtinBase64Encode(a ast.Value) (ast.Value, error) {
Expand Down

0 comments on commit 8b33bca

Please sign in to comment.