For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
| 1913 | |
| 1914 | // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. |
| 1915 | void ImGuiStorage::BuildSortByKey() |
| 1916 | { |
| 1917 | struct StaticFunc |
| 1918 | { |
| 1919 | static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) |
| 1920 | { |
| 1921 | // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. |
| 1922 | if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; |
| 1923 | if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; |
| 1924 | return 0; |
| 1925 | } |
| 1926 | }; |
| 1927 | if (Data.Size > 1) |
| 1928 | ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); |
| 1929 | } |
| 1930 | |
| 1931 | int ImGuiStorage::GetInt(ImGuiID key, int default_val) const |
| 1932 | { |
nothing calls this directly
no outgoing calls
no test coverage detected