Conversion#binaryToHexDigit(boolean[], int): Simplify implementation by removing redundant conditions.

This commit is contained in:
pascalschumacher 2019-12-22 12:42:16 +01:00
parent 670a832d4d
commit ff05749cdc
1 changed files with 4 additions and 4 deletions

View File

@ -311,19 +311,19 @@ public class Conversion {
throw new IllegalArgumentException("Cannot convert an empty array.");
}
if (src.length > srcPos + 3 && src[srcPos + 3]) {
if (src.length > srcPos + 2 && src[srcPos + 2]) {
if (src.length > srcPos + 1 && src[srcPos + 1]) {
if (src[srcPos + 2]) {
if (src[srcPos + 1]) {
return src[srcPos] ? 'f' : 'e';
}
return src[srcPos] ? 'd' : 'c';
}
if (src.length > srcPos + 1 && src[srcPos + 1]) {
if (src[srcPos + 1]) {
return src[srcPos] ? 'b' : 'a';
}
return src[srcPos] ? '9' : '8';
}
if (src.length > srcPos + 2 && src[srcPos + 2]) {
if (src.length > srcPos + 1 && src[srcPos + 1]) {
if (src[srcPos + 1]) {
return src[srcPos] ? '7' : '6';
}
return src[srcPos] ? '5' : '4';