Update encoding.go

optimization code
This commit is contained in:
Sarlor 2018-06-07 12:38:02 +08:00 committed by GitHub
parent 90b22773e9
commit 02cade48f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,10 +53,9 @@ func hexToCompact(hex []byte) []byte {
func compactToHex(compact []byte) []byte { func compactToHex(compact []byte) []byte {
base := keybytesToHex(compact) base := keybytesToHex(compact)
base = base[:len(base)-1] // delete terminator flag
// apply terminator flag if base[0] < 2 {
if base[0] >= 2 { base = base[:len(base)-1]
base = append(base, 16)
} }
// apply odd flag // apply odd flag
chop := 2 - base[0]&1 chop := 2 - base[0]&1