2019-03-07 01:55:38 +03:00
|
|
|
package brotli
|
|
|
|
|
|
|
|
/* Copyright 2010 Google Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
Distributed under MIT license.
|
|
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Function to find maximal matching prefixes of strings. */
|
2019-03-16 03:24:40 +03:00
|
|
|
func findMatchLengthWithLimit(s1 []byte, s2 []byte, limit uint) uint {
|
2019-03-07 01:55:38 +03:00
|
|
|
var matched uint = 0
|
2020-05-05 02:09:27 +03:00
|
|
|
_, _ = s1[limit-1], s2[limit-1] // bounds check
|
2019-03-07 01:55:38 +03:00
|
|
|
for matched < limit && s1[matched] == s2[matched] {
|
|
|
|
matched++
|
|
|
|
}
|
|
|
|
return matched
|
|
|
|
}
|