Replace another for loop with copy in packDomainName
This change is included as a separate commit because this loop is not as trivial as the others.
This commit is contained in:
parent
8d08c56229
commit
3b3a5b7c6a
14
msg.go
14
msg.go
|
@ -251,15 +251,13 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
|
||||||
}
|
}
|
||||||
offset := off
|
offset := off
|
||||||
off++
|
off++
|
||||||
for j := begin; j < i; j++ {
|
if off+(i-begin) > lenmsg {
|
||||||
if off+1 > lenmsg {
|
return lenmsg, labels, ErrBuf
|
||||||
return lenmsg, labels, ErrBuf
|
|
||||||
}
|
|
||||||
if msg != nil {
|
|
||||||
msg[off] = bs[j]
|
|
||||||
}
|
|
||||||
off++
|
|
||||||
}
|
}
|
||||||
|
if msg != nil {
|
||||||
|
copy(msg[off:], bs[begin:i])
|
||||||
|
}
|
||||||
|
off += i - begin
|
||||||
if compress && !bsFresh {
|
if compress && !bsFresh {
|
||||||
roBs = string(bs)
|
roBs = string(bs)
|
||||||
bsFresh = true
|
bsFresh = true
|
||||||
|
|
Loading…
Reference in New Issue