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