Skip color dist calc if exact match

This commit is contained in:
Astrash committed 2022-11-26 14:05:39 +11:00
1 parent 878bede60b
commit a97273f358
1 file changed
+4 -3
@@ -20,11 +20,12 @@ public class ClosestMatchColorConverter<T> implements ColorConverter<T> {
int closest = 0;
int smallestDistance = Integer.MAX_VALUE;
for(int compare : colors) {
int distance = ColorUtil.distance(color, compare);
if(distance == 0) {
if(color == compare) {
closest = compare;
break;
} else if(distance < smallestDistance) {
}
int distance = ColorUtil.distance(color, compare);
if(distance < smallestDistance) {
smallestDistance = distance;
closest = compare;
}