For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
| 1716 | |
| 1717 | // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. |
| 1718 | void ImGuiStorage::BuildSortByKey() |
| 1719 | { |
| 1720 | struct StaticFunc |
| 1721 | { |
| 1722 | static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) |
| 1723 | { |
| 1724 | // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. |
| 1725 | if (((const Pair*)lhs)->key > ((const Pair*)rhs)->key) return +1; |
| 1726 | if (((const Pair*)lhs)->key < ((const Pair*)rhs)->key) return -1; |
| 1727 | return 0; |
| 1728 | } |
| 1729 | }; |
| 1730 | if (Data.Size > 1) |
| 1731 | ImQsort(Data.Data, (size_t)Data.Size, sizeof(Pair), StaticFunc::PairCompareByID); |
| 1732 | } |
| 1733 | |
| 1734 | int ImGuiStorage::GetInt(ImGuiID key, int default_val) const |
| 1735 | { |
nothing calls this directly
no outgoing calls
no test coverage detected