public int compareTo()

in openwire-core/src/main/java/org/apache/activemq/openwire/buffer/Buffer.java [178:216]


    public int compareTo(Buffer o) {
        if (this == o) {
            return 0;
        }

        byte[] data = this.data;
        int offset = this.offset;
        int length = this.length;

        int oLength = o.length;
        int oOffset = o.offset;
        byte[] oData = o.data;

        int minLength = Math.min(length, oLength);
        if (offset == oOffset) {
            int pos = offset;
            int limit = minLength + offset;
            while (pos < limit) {
                int b1 = 0xFF & data[pos];
                int b2 = 0xFF & oData[pos];
                if (b1 != b2) {
                    return b1 - b2;
                }
                pos++;
            }
        } else {
            int offset1 = offset;
            int offset2 = oOffset;
            while (minLength-- != 0) {
                int b1 = 0xFF & data[offset1++];
                int b2 = 0xFF & oData[offset2++];
                if (b1 != b2) {
                    return b1 - b2;
                }
            }
        }

        return length - oLength;
    }