internal: use bytes.Clone

Change-Id: Ia96ddd520a7bd2fd53bff55315c6fac04ae96a2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/435282
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
cuiweixie 2022-09-28 00:29:48 +08:00 committed by Gopher Robot
parent 09919ac339
commit a59e614aa1
3 changed files with 6 additions and 7 deletions

View file

@ -9,6 +9,7 @@ package encodemeta
// instrumentation is turned on.
import (
"bytes"
"crypto/md5"
"encoding/binary"
"fmt"
@ -82,8 +83,7 @@ func (b *CoverageMetaDataBuilder) AddFunc(f coverage.FuncDesc) uint {
lit = 1
}
b.tmp = uleb128.AppendUleb128(b.tmp, lit)
fd.encoded = make([]byte, len(b.tmp))
copy(fd.encoded, b.tmp)
fd.encoded = bytes.Clone(b.tmp)
rv := uint(len(b.funcs))
b.funcs = append(b.funcs, fd)
return rv