bundles/org.tukani.xz/src/org/tukaani/xz/lz/LZEncoder.java
public int getMatchLen(int dist, int lenLimit) {
        int backPos = readPos - dist - 1;
        int len = 0;

        while (len < lenLimit && buf[readPos + len] == buf[backPos + len])
            ++len;

        return len;
    }
public int getMatchLen(int dist, int lenLimit) {
        int backPos = readPos - dist - 1;
        int len = 0;

        while (len < lenLimit && buf[readPos + len] == buf[backPos + len])
            ++len;

        return len;
    }
Get the length of a match at the given distance.

@param       dist        zero-based distance of the match to test
@param       lenLimit    don't test for a match longer than this

@return      length of the match; it is in the range [0, lenLimit]