File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
main/java/com/trivago/fastutilconcurrentwrapper/util
test/java/com/trivago/fastutilconcurrentwrapper/util Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ public static boolean nonEmpty (byte @Nullable [] b) {
4141 return b != null && b .length > 0 ;
4242 }
4343
44+ public static int len (byte @ Nullable [] b ){
45+ return b != null ? b .length : 0 ;
46+ }
47+
4448 /**
4549 A common case of copying arrays from start to [start .. min(len1,len2))
4650 Used when increasing or decreasing the array length.
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ void testIsEmptyAndNonEmpty() {
3232 assertFalse (JBytes .nonEmpty (null ));
3333 assertFalse (JBytes .nonEmpty (new byte [0 ]));
3434 assertTrue (JBytes .nonEmpty (new byte []{1 }));
35+
36+ assertEquals (0 , JBytes .len (null ));
37+ assertEquals (0 , JBytes .len (new byte [0 ]));
38+ assertEquals (1 , JBytes .len (new byte []{0 }));
3539 }
3640
3741 @ Test
You can’t perform that action at this time.
0 commit comments