For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
| 1891 | |
| 1892 | // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. |
| 1893 | void ImGuiStorage::BuildSortByKey() |
| 1894 | { |
| 1895 | struct StaticFunc |
| 1896 | { |
| 1897 | static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) |
| 1898 | { |
| 1899 | // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. |
| 1900 | if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; |
| 1901 | if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; |
| 1902 | return 0; |
| 1903 | } |
| 1904 | }; |
| 1905 | if (Data.Size > 1) |
| 1906 | ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); |
| 1907 | } |
| 1908 | |
| 1909 | int ImGuiStorage::GetInt(ImGuiID key, int default_val) const |
| 1910 | { |
nothing calls this directly
no outgoing calls
no test coverage detected