Replace bsFresh variable with bsDirty in packDomainName

This avoids needing to initialise it to true.
This commit is contained in:
Tom Thorogood 2018-11-26 15:59:16 +10:30
parent 5547fd63a0
commit 896cef4ce4
No known key found for this signature in database
GPG Key ID: 86C63CDA416C6D2F
1 changed files with 10 additions and 7 deletions

17
msg.go
View File

@ -211,10 +211,13 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
pointer := -1
// Emit sequence of counted strings, chopping at dots.
begin := 0
var bs []byte
roBs, bsFresh, wasDot := s, true, false
var (
begin int
bs []byte
roBs = s
bsDirty bool
wasDot bool
)
loop:
for i := 0; i < ls; i++ {
var c byte
@ -244,7 +247,7 @@ loop:
ls -= 2
}
bsFresh = false
bsDirty = true
wasDot = false
case '.':
if wasDot {
@ -264,9 +267,9 @@ loop:
return lenmsg, labels, ErrBuf
}
if compress && !bsFresh {
if compress && bsDirty {
roBs = string(bs[:ls])
bsFresh = true
bsDirty = false
}
// Don't try to compress '.'