| 1 | // SPDX-License-Identifier: 0BSD |
| 2 | // SPDX-FileCopyrightText: The XZ for Java authors and contributors |
| 3 | // SPDX-FileContributor: Lasse Collin <[email protected]> |
| 4 | |
| 5 | package org.tukaani.xz.lz; |
| 6 | |
| 7 | // See the version in the src9 directory for documentation. |
| 8 | final class MatchLength { |
| 9 | static final int EXTRA_SIZE = 0; |
| 10 | |
| 11 | static int getLen(byte[] buf, int off, int delta, int len, int lenLimit) { |
| 12 | assert off >= 0; |
| 13 | assert delta > 0; |
| 14 | assert len >= 0; |
| 15 | assert lenLimit >= len; |
| 16 | |
| 17 | lenLimit += off; |
| 18 | int i = off + len; |
| 19 | |
| 20 | while (i < lenLimit && buf[i] == buf[i - delta]) |
| 21 | ++i; |
| 22 | |
| 23 | return i - off; |
| 24 | } |
| 25 | } |