For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
| 1937 | |
| 1938 | // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. |
| 1939 | void ImGuiStorage::BuildSortByKey() |
| 1940 | { |
| 1941 | struct StaticFunc |
| 1942 | { |
| 1943 | static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) |
| 1944 | { |
| 1945 | // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. |
| 1946 | if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; |
| 1947 | if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; |
| 1948 | return 0; |
| 1949 | } |
| 1950 | }; |
| 1951 | if (Data.Size > 1) |
| 1952 | ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); |
| 1953 | } |
| 1954 | |
| 1955 | int ImGuiStorage::GetInt(ImGuiID key, int default_val) const |
| 1956 | { |
nothing calls this directly
no outgoing calls
no test coverage detected