A couple of tweaks

This commit is contained in:
Andy Balholm 2020-05-04 16:09:27 -07:00
parent ac459dee64
commit 3c3658f2fb
2 changed files with 4 additions and 1 deletions

View File

@ -502,7 +502,9 @@ func updateNodes(num_bytes uint, block_start uint, pos uint, ringbuffer []byte,
var cost float32 = dist_cost + float32(getCopyExtra(copycode)) + zopfliCostModelGetCommandCost(model, cmdcode)
if cost < nodes[pos+len].u.cost {
updateZopfliNode(nodes, pos, start, uint(len), len_code, dist, 0, cost)
result = brotli_max_size_t(result, uint(len))
if len > result {
result = len
}
}
}
}

View File

@ -9,6 +9,7 @@ package brotli
/* Function to find maximal matching prefixes of strings. */
func findMatchLengthWithLimit(s1 []byte, s2 []byte, limit uint) uint {
var matched uint = 0
_, _ = s1[limit-1], s2[limit-1] // bounds check
for matched < limit && s1[matched] == s2[matched] {
matched++
}