Skip to content

Commit

Permalink
Use bytes.Clone, added in Go 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Apr 12, 2024
1 parent 485b746 commit 8868a69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jsontext/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package jsontext

import (
"bytes"
"math"
"strconv"

Expand Down Expand Up @@ -186,8 +187,7 @@ func (t Token) Clone() Token {
if uint64(raw.previousOffsetStart()) != t.num {
panic(invalidTokenPanic)
}
// TODO(https://go.dev/issue/45038): Use bytes.Clone.
buf := append([]byte(nil), raw.PreviousBuffer()...)
buf := bytes.Clone(raw.PreviousBuffer())
return Token{raw: &decodeBuffer{buf: buf, prevStart: 0, prevEnd: len(buf)}}
}
return t
Expand Down

0 comments on commit 8868a69

Please sign in to comment.