mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user