Fix ineffective sorting of palettes pre-packing

We were sorting the *IDs*, not the proto-palettes...
This commit is contained in:
ISSOtm
2024-08-08 11:31:46 +02:00
parent 1ad9383042
commit 0f1137c6ec
2 changed files with 16 additions and 4 deletions

View File

@@ -362,7 +362,19 @@ std::tuple<DefaultInitVec<size_t>, size_t>
DefaultInitVec<size_t> sortedProtoPalIDs(protoPalettes.size());
sortedProtoPalIDs.clear();
for (size_t i = 0; i < protoPalettes.size(); ++i) {
sortedProtoPalIDs.insert(std::lower_bound(RANGE(sortedProtoPalIDs), i), i);
sortedProtoPalIDs.insert(
std::lower_bound(
RANGE(sortedProtoPalIDs),
i,
[&protoPalettes](size_t left, size_t right) {
ProtoPalette const &lhs = protoPalettes[left];
ProtoPalette const &rhs = protoPalettes[right];
return lhs.size()
> rhs.size(); // We want the proto-pals to be sorted *largest first*!
}
),
i
);
}
// Begin with all proto-palettes queued up for insertion
std::queue<ProtoPalAttrs> queue(std::deque<ProtoPalAttrs>(RANGE(sortedProtoPalIDs)));