fix: optimization: PVS-Studio warning V831

Replaced 'at()' method with 'operator[]' to improve performance.

The 'at()' method performs bounds checking, which can introduce overhead. Using 'operator[]' bypasses this check and can improve performance when you are certain that the index is within bounds.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-02 02:38:54 +03:00
committed by Pugemon
parent 1bdc9cf759
commit f3f872c7a3
6 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ speakerid_t audio::play(
if (!sound->variants.empty()) {
size_t index = rand() % (sound->variants.size() + 1);
if (index < sound->variants.size()) {
sound = sound->variants.at(index).get();
sound = sound->variants[index].get();
}
}
auto speaker_ptr = sound->newInstance(priority, channel);