Use NextLabel in compressionLenHelper
This avoids the allocation of Split and should have slightly better performance.
This commit is contained in:
parent
3b3a5b7c6a
commit
8e6e188a87
8
msg.go
8
msg.go
|
@ -985,11 +985,9 @@ func compressionLenHelper(c map[string]int, s string, currentLen int) int {
|
|||
return 0
|
||||
}
|
||||
initLen := currentLen
|
||||
pref := ""
|
||||
prev := s
|
||||
lbs := Split(s)
|
||||
for j := 0; j < len(lbs); j++ {
|
||||
pref = s[lbs[j]:]
|
||||
for off, end := 0, false; !end; off, end = NextLabel(s, off) {
|
||||
pref := s[off:]
|
||||
currentLen += len(prev) - len(pref)
|
||||
prev = pref
|
||||
if _, ok := c[pref]; !ok {
|
||||
|
@ -999,7 +997,7 @@ func compressionLenHelper(c map[string]int, s string, currentLen int) int {
|
|||
}
|
||||
} else {
|
||||
added := currentLen - initLen
|
||||
if j > 0 {
|
||||
if off > 0 {
|
||||
// We added a new PTR
|
||||
added += 2
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue