Bug 1626570 - Improve handling of copying arrays in dom/html/. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D73626
This commit is contained in:
Simon Giesecke
2020-05-05 10:08:15 +00:00
parent 5ab46b5ad0
commit 2084169ef6
2 changed files with 13 additions and 9 deletions

View File

@@ -3486,13 +3486,17 @@ void HTMLMediaElement::UpdateOutputTrackSources() {
}
// Then work out the differences.
for (const auto& track :
AutoTArray<RefPtr<MediaTrack>, 4>(mediaTracksToAdd)) {
if (mOutputTrackSources.GetWeak(track->GetId())) {
mediaTracksToAdd.RemoveElement(track);
trackSourcesToRemove.RemoveElement(track->GetId());
}
}
mediaTracksToAdd.RemoveElementsAt(
std::remove_if(mediaTracksToAdd.begin(), mediaTracksToAdd.end(),
[this, &trackSourcesToRemove](const auto& track) {
const bool remove =
mOutputTrackSources.GetWeak(track->GetId());
if (remove) {
trackSourcesToRemove.RemoveElement(track->GetId());
}
return remove;
}),
mediaTracksToAdd.end());
// First remove stale track sources.
for (const auto& id : trackSourcesToRemove) {