private static int matchLen(byte[] oldBuf, int oldOffset, byte[] newBuf, int newOffset) {
    int end = Math.min(oldBuf.length - oldOffset, newBuf.length - newOffset);
    for (int i = 0; i < end; i++) {
      if (oldBuf[oldOffset + i] != newBuf[newOffset + i]) {
        return i;
      }
    }
    return end;
  }
private static int matchLen(byte[] oldBuf, int oldOffset, byte[] newBuf, int newOffset)