encode_other.go 522 B

123456789101112131415161718
  1. // Copyright 2016 The Snappy-Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build !amd64 appengine !gc noasm
  5. package snappy
  6. // extendMatch returns the largest k such that k <= len(src) and that
  7. // src[i:i+k-j] and src[j:k] have the same contents.
  8. //
  9. // It assumes that:
  10. // 0 <= i && i < j && j <= len(src)
  11. func extendMatch(src []byte, i, j int) int {
  12. for ; j < len(src) && src[i] == src[j]; i, j = i+1, j+1 {
  13. }
  14. return j
  15. }