From 3c3658f2fb20575bec7df172800be86451b53bcc Mon Sep 17 00:00:00 2001 From: Andy Balholm Date: Mon, 4 May 2020 16:09:27 -0700 Subject: [PATCH] A couple of tweaks --- backward_references_hq.go | 4 +++- find_match_length.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backward_references_hq.go b/backward_references_hq.go index 5eac736..bd2de48 100644 --- a/backward_references_hq.go +++ b/backward_references_hq.go @@ -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 + } } } } diff --git a/find_match_length.go b/find_match_length.go index 14d350a..6730119 100644 --- a/find_match_length.go +++ b/find_match_length.go @@ -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++ }