Small improvement to sfx randomize button. (#2219)

Should result in less allocations.
This commit is contained in:
Christopher Leggett 2022-12-21 00:31:51 -05:00 committed by GitHub
parent 1a10d8f627
commit 8c8111c7b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,10 +303,9 @@ void Draw_SfxTab(const std::string& tabId, const std::map<u16, std::tuple<std::s
ImGui::SameLine();
ImGui::PushItemWidth(-FLT_MIN);
if (ImGui::Button(randomizeButton.c_str())) {
while (true) {
auto it = map.begin();
std::advance(it, rand() % map.size());
const auto& [value, seqData] = *it;
while (true) {
const auto& [value, seqData] = *std::next(it, rand() % map.size());
const auto& [name, sfxKey, seqType] = seqData;
if (seqType & type) {
CVar_SetS32(cvarKey.c_str(), value);