From 7c2bd98e4436abd47fa4a567aa6452cb2f9bc123 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Fri, 5 Jan 2018 20:14:34 +0100 Subject: [PATCH] Simplified logic for removal of destroyed sounds --- v3/src/sound/BaseSoundManager.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/v3/src/sound/BaseSoundManager.js b/v3/src/sound/BaseSoundManager.js index 3583879ba..b53a5f902 100644 --- a/v3/src/sound/BaseSoundManager.js +++ b/v3/src/sound/BaseSoundManager.js @@ -198,13 +198,9 @@ var BaseSoundManager = new Class({ * @param {number} delta - The delta time elapsed since the last frame. */ update: function (time, delta) { - this.sounds.sort(function (s1, s2) { - return (s1.pendingRemove === s2.pendingRemove) ? 0 : s1 ? 1 : -1; - }); - for (var i = 0; i < this.sounds.length; i++) { + for (var i = this.sounds.length - 1; i >= 0; i--) { if (this.sounds[i].pendingRemove) { - this.sounds.length = i; - break; + this.sounds.splice(i, 1); } } this.sounds.forEach(function (sound) {