code: static int sharedPrefixLength(ByteBuffer a, int aStart, ByteBuffer b, int bStart) {
      int i = 0;
      final int max = Math.min(a.remaining() - aStart, b.remaining() - bStart);
      aStart += a.position();
      bStart += b.position();
      while (i < max && a.get(aStart++) == b.get(bStart++)) {
        i++;
      }
      return i;
    }
docs: Compute the length of the shared prefix between two byte sequences.