diff --git a/patch.go b/patch.go index 535d3c7..67ed0e3 100644 --- a/patch.go +++ b/patch.go @@ -3,6 +3,7 @@ package jsonpatch import ( "encoding/json" "reflect" + "slices" ) // JSONPatch format is specified in RFC 6902 @@ -40,13 +41,7 @@ func (l JSONPatchList) Raw() []byte { // List returns a copy of the underlying JSONPatch slice func (l JSONPatchList) List() []JSONPatch { - ret := make([]JSONPatch, l.Len()) - - for i, patch := range l.list { - ret[i] = patch - } - - return ret + return slices.Clone(l.list) } // CreateJSONPatch compares two JSON data structures and creates a JSONPatch according to RFC 6902