Fix ProtoPalette::compare

The function only stopped at the end of the *arrays*,
not of *their used portions*!
This could cause false negatives one way or the other.

This appears not to affect the palette packing, since the packing algorithm
deals with them efficiently; but it should speed up processing slightly,
and as the test changes show, it also improves the UX of palette packing
error messages!
This commit is contained in:
ISSOtm
2024-08-14 17:30:56 +02:00
parent c42e856efb
commit 68a6abd00e
3 changed files with 5 additions and 12 deletions

View File

@@ -46,7 +46,7 @@ ProtoPalette::ComparisonResult ProtoPalette::compare(ProtoPalette const &other)
auto ours = _colorIndices.begin(), theirs = other._colorIndices.begin();
bool weBigger = true, theyBigger = true;
while (ours != _colorIndices.end() && theirs != other._colorIndices.end()) {
while (ours != end() && theirs != other.end()) {
if (*ours == *theirs) {
++ours;
++theirs;
@@ -58,8 +58,8 @@ ProtoPalette::ComparisonResult ProtoPalette::compare(ProtoPalette const &other)
weBigger = false;
}
}
weBigger &= theirs == other._colorIndices.end();
theyBigger &= ours == _colorIndices.end();
weBigger &= theirs == other.end();
theyBigger &= ours == end();
return theyBigger ? THEY_BIGGER : (weBigger ? WE_BIGGER : NEITHER);
}