Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioManager: simplify the code for playing ambient sounds, evaluate & remove the old TODO comment #9288

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

oleg-derevenetz
Copy link
Collaborator

@oleg-derevenetz oleg-derevenetz commented Nov 20, 2024

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 of erase()+std::remove_if() instead of calling erase() 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 in std::vector data is arranged sequentially in memory, which is very good for the CPU cache and quite compensates std::vector drawbacks in this particular case.

@oleg-derevenetz oleg-derevenetz added improvement New feature, request or improvement audio Sound and music related stuff labels Nov 20, 2024
@oleg-derevenetz oleg-derevenetz added this to the 1.1.5 milestone Nov 20, 2024
@oleg-derevenetz oleg-derevenetz marked this pull request as ready for review November 27, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Sound and music related stuff improvement New feature, request or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant