private int match() {
        final int last = in.readableBytes() - boundaryBytes.length;
        int off = 0;

        // Loop over all possible match positions in text
        NEXT:
        while (off <= last) {
            // Loop over pattern from right to left
            for (int j = boundaryBytes.length - 1; j >= 0; j--) {
                final byte ch = in.getByte(off + j);
                if (ch != boundaryBytes[j]) {
                    // Shift search to the right by the maximum of the
                    // bad character shift and the good suffix shift
                    off += Math.max(j + 1 - badCharacters[ch & 0x7F], goodSuffixes[j]);
                    continue NEXT;
                }
            }
            // Entire pattern matched starting at off
            return off;
        }
        return -1;
    }
Finds the boundary in the given buffer using Boyer-Moore algorithm.
Copied from {@link Pattern}

@return -1 if there is no match or index where the match starts
core/src/main/java/com/linecorp/armeria/common/multipart/MimeParser.java