@ SuppressWarnings ( "checkstyle:ReturnCount" ) public static int compareBuff ( final DirectBuffer o1 , final DirectBuffer o2 ) { requireNonNull ( o1 ) ; requireNonNull ( o2 ) ; if ( o1 . equals ( o2 ) ) { return 0 ; } final int minLength = Math . min ( o1 . capacity ( ) , o2 . capacity ( ) ) ; final int minWords = minLength / Long . BYTES ; for ( int i = 0 ; i < minWords * Long . BYTES ; i += Long . BYTES ) { final long lw = o1 . getLong ( i , BIG_ENDIAN ) ; final long rw = o2 . getLong ( i , BIG_ENDIAN ) ; final int diff = Long . compareUnsigned ( lw , rw ) ; if ( diff != 0 ) { return diff ; } } for ( int i = minWords * Long . BYTES ; i < minLength ; i ++ ) { final int lw = Byte . toUnsignedInt ( o1 . getByte ( i ) ) ; final int rw = Byte . toUnsignedInt ( o2 . getByte ( i ) ) ; final int result = Integer . compareUnsigned ( lw , rw ) ; if ( result != 0 ) { return result ; } } return o1 . capacity ( ) - o2 . capacity ( ) ; }
Lexicographically compare two buffers .