code: private static int findMatchingLength(ByteBuf in, int minIndex, int inIndex, int maxIndex) {
          int matched = 0;
  
          while (inIndex <= maxIndex - 4 &&
                  in.getInt(inIndex) == in.getInt(minIndex + matched)) {
              inIndex += 4;
              matched += 4;
          }
  
          while (inIndex < maxIndex && in.getByte(minIndex + matched) == in.getByte(inIndex)) {
              ++inIndex;
              ++matched;
          }
  
          return matched;
      }
docs: Iterates over the supplied input buffer between the supplied minIndex and
  maxIndex to find how long our matched copy overlaps with an already-written
  literal value.
  
  @param in The input buffer to scan over
  @param minIndex The index in the input buffer to start scanning from
  @param inIndex The index of the start of our copy
  @param maxIndex The length of our input buffer
  @return The number of bytes for which our candidate copy is a repeat of