mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
use in built bytes clone method
This commit is contained in:
parent
6f2cbb7a27
commit
4ee67b8d25
1 changed files with 3 additions and 8 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
|
@ -37,14 +38,8 @@ func FromHex(s string) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyBytes returns an exact copy of the provided bytes.
|
// CopyBytes returns an exact copy of the provided bytes.
|
||||||
func CopyBytes(b []byte) (copiedBytes []byte) {
|
func CopyBytes(b []byte) []byte {
|
||||||
if b == nil {
|
return bytes.Clone(b)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
copiedBytes = make([]byte, len(b))
|
|
||||||
copy(copiedBytes, b)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// has0xPrefix validates str begins with '0x' or '0X'.
|
// has0xPrefix validates str begins with '0x' or '0X'.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue