AudioManager: simplify the code for playing ambient sounds, evaluate & remove the old TODO comment #9288
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a TODO comment that suggested choosing a more suitable container for the ambient sound control logic. The main issue of the container used (unsorted
std::vector
) was the problem of quickly finding and deleting items. After some thought, I decided to leave the current logic unchanged except for some minor optimizations (e.g. using oferase()
+std::remove_if()
instead of callingerase()
for each element separately when possible), because the number of elements in the vector in this case is usually very small (even theoretically it will always be less than 50, and in reality, as a rule, it is much less than 10), and at the same time instd::vector
data is arranged sequentially in memory, which is very good for the CPU cache and quite compensatesstd::vector
drawbacks in this particular case.