From c5de9361d7352eeb0c9c62ec675a3d32f1d63499 Mon Sep 17 00:00:00 2001 From: Ross Kirsling Date: Tue, 5 Dec 2023 20:02:00 -0800 Subject: [PATCH] Use find instead of contains for unordered_map https://bugs.webkit.org/show_bug.cgi?id=265920 Reviewed by Don Olmstead. Build fix for PlayStation. `map.contains(element)` may read nicely, but `map.find(element) != map.end()` is still a one-liner. Let's stick to the latter for the moment since it's non-trivial to add a new method to an existing STL container. * Source/WebCore/platform/graphics/SourceBufferPrivate.cpp: (WebCore::SourceBufferPrivate::addTrackBuffer): (WebCore::SourceBufferPrivate::validateInitializationSegment): Canonical link: https://commits.webkit.org/271589@main --- Source/WebCore/platform/graphics/SourceBufferPrivate.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp b/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp index ab7217bc01af..458e6b44511d 100644 --- a/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp +++ b/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp @@ -538,7 +538,7 @@ uint64_t SourceBufferPrivate::totalTrackBufferSizeInBytes() const void SourceBufferPrivate::addTrackBuffer(TrackID trackId, RefPtr&& description) { - ASSERT(!m_trackBufferMap.contains(trackId)); + ASSERT(m_trackBufferMap.find(trackId) == m_trackBufferMap.end()); m_hasAudio = m_hasAudio || description->isAudio(); m_hasVideo = m_hasVideo || description->isVideo(); @@ -640,21 +640,21 @@ bool SourceBufferPrivate::validateInitializationSegment(const SourceBufferPrivat // IDs match the ones in the first initialization segment. if (segment.audioTracks.size() >= 2) { for (auto& audioTrackInfo : segment.audioTracks) { - if (!m_trackBufferMap.contains(audioTrackInfo.track->id())) + if (m_trackBufferMap.find(audioTrackInfo.track->id()) == m_trackBufferMap.end()) return false; } } if (segment.videoTracks.size() >= 2) { for (auto& videoTrackInfo : segment.videoTracks) { - if (!m_trackBufferMap.contains(videoTrackInfo.track->id())) + if (m_trackBufferMap.find(videoTrackInfo.track->id()) == m_trackBufferMap.end()) return false; } } if (segment.textTracks.size() >= 2) { for (auto& textTrackInfo : segment.videoTracks) { - if (!m_trackBufferMap.contains(textTrackInfo.track->id())) + if (m_trackBufferMap.find(textTrackInfo.track->id()) == m_trackBufferMap.end()) return false; } }