For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
| 1429 | |
| 1430 | // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. |
| 1431 | void ImGuiStorage::BuildSortByKey() |
| 1432 | { |
| 1433 | struct StaticFunc |
| 1434 | { |
| 1435 | static int PairCompareByID(const void* lhs, const void* rhs) |
| 1436 | { |
| 1437 | // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. |
| 1438 | if (((const Pair*)lhs)->key > ((const Pair*)rhs)->key) return +1; |
| 1439 | if (((const Pair*)lhs)->key < ((const Pair*)rhs)->key) return -1; |
| 1440 | return 0; |
| 1441 | } |
| 1442 | }; |
| 1443 | if (Data.Size > 1) |
| 1444 | qsort(Data.Data, (size_t)Data.Size, sizeof(Pair), StaticFunc::PairCompareByID); |
| 1445 | } |
| 1446 | |
| 1447 | int ImGuiStorage::GetInt(ImGuiID key, int default_val) const |
| 1448 | { |
nothing calls this directly
no outgoing calls
no test coverage detected