| 193 | } |
| 194 | |
| 195 | void TypesHolder::SortBySpec() |
| 196 | { |
| 197 | auto const & cl = classif(); |
| 198 | auto const getPriority = [&cl](uint32_t type) { return cl.GetObject(type)->GetMaxOverlaysPriority(); }; |
| 199 | |
| 200 | auto const & checker = UselessTypesChecker::Instance(); |
| 201 | auto const & subtypes = ftypes::Subtypes::Instance(); |
| 202 | |
| 203 | std::stable_sort(begin(), end(), [&checker, &getPriority, &subtypes](uint32_t t1, uint32_t t2) |
| 204 | { |
| 205 | std::optional<bool> const comparisonResultBasedOnTypeRelation = |
| 206 | subtypes.ComparisonResultBasedOnTypeRelation(t1, t2); |
| 207 | if (comparisonResultBasedOnTypeRelation.has_value()) |
| 208 | return comparisonResultBasedOnTypeRelation.value(); |
| 209 | |
| 210 | int const p1 = getPriority(t1); |
| 211 | int const p2 = getPriority(t2); |
| 212 | if (p1 != p2) |
| 213 | return p1 > p2; |
| 214 | |
| 215 | // Score - less is better. |
| 216 | return checker.Score(t1) < checker.Score(t2); |
| 217 | }); |
| 218 | } |
| 219 | |
| 220 | vector<string> TypesHolder::ToObjectNames() const |
| 221 | { |