[MediaStream] Use iterator-based loops instead of index-based loops

https://bugs.webkit.org/show_bug.cgi?id=125021

Patch by Roger Zanoni <rogerzanoni@gmail.com> on 2013-12-02
Reviewed by Eric Carlson.

Also, changing iterator variable names from iter to it and
initializing an 'end' variable in each loop instead of evaluating
'collection.end()' multiple times.

No new tests, covered by existing ones.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::cloneMediaStreamTrackVector):
(WebCore::MediaStream::haveTrackWithSource):
(WebCore::MediaStream::getTrackById):
(WebCore::MediaStream::trackDidEnd):
(WebCore::MediaStream::scheduledEventTimerFired):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1a680386
2013-12-02 Roger Zanoni <rogerzanoni@gmail.com>
[MediaStream] Use iterator-based loops instead of index-based loops
https://bugs.webkit.org/show_bug.cgi?id=125021
Reviewed by Eric Carlson.
Also, changing iterator variable names from iter to it and
initializing an 'end' variable in each loop instead of evaluating
'collection.end()' multiple times.
No new tests, covered by existing ones.
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::cloneMediaStreamTrackVector):
(WebCore::MediaStream::haveTrackWithSource):
(WebCore::MediaStream::getTrackById):
(WebCore::MediaStream::trackDidEnd):
(WebCore::MediaStream::scheduledEventTimerFired):
2013-12-02 Rob Buis <rob.buis@samsung.com>
[css shapes] Parse new ellipse shape syntax
......@@ -137,8 +137,8 @@ PassRefPtr<MediaStream> MediaStream::clone()
void MediaStream::cloneMediaStreamTrackVector(Vector<RefPtr<MediaStreamTrack>>& destination, const Vector<RefPtr<MediaStreamTrack>>& source)
{
for (unsigned i = 0; i < source.size(); i++)
destination.append(source[i]->clone());
for (auto it = source.begin(), end = source.end(); it != end; ++it)
destination.append((*it)->clone());
}
void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode& ec)
......@@ -217,15 +217,15 @@ bool MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack)
bool MediaStream::haveTrackWithSource(PassRefPtr<MediaStreamSource> source)
{
if (source->type() == MediaStreamSource::Audio) {
for (auto iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) {
if ((*iter)->source() == source.get())
for (auto it = m_audioTracks.begin(), end = m_audioTracks.end(); it != end; ++it) {
if ((*it)->source() == source.get())
return true;
}
return false;
}
for (auto iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) {
if ((*iter)->source() == source.get())
for (auto it = m_videoTracks.begin(), end = m_videoTracks.end(); it != end; ++it) {
if ((*it)->source() == source.get())
return true;
}
......@@ -234,14 +234,14 @@ bool MediaStream::haveTrackWithSource(PassRefPtr<MediaStreamSource> source)
MediaStreamTrack* MediaStream::getTrackById(String id)
{
for (auto iter = m_audioTracks.begin(); iter != m_audioTracks.end(); ++iter) {
if ((*iter)->id() == id)
return (*iter).get();
for (auto it = m_audioTracks.begin(), end = m_audioTracks.end(); it != end; ++it) {
if ((*it)->id() == id)
return (*it).get();
}
for (auto iter = m_videoTracks.begin(); iter != m_videoTracks.end(); ++iter) {
if ((*iter)->id() == id)
return (*iter).get();
for (auto it = m_videoTracks.begin(), end = m_videoTracks.end(); it != end; ++it) {
if ((*it)->id() == id)
return (*it).get();
}
return nullptr;
......@@ -249,14 +249,15 @@ MediaStreamTrack* MediaStream::getTrackById(String id)
void MediaStream::trackDidEnd()
{
for (size_t i = 0; i < m_audioTracks.size(); ++i)
if (!m_audioTracks[i]->ended())
for (auto it = m_audioTracks.begin(), end = m_audioTracks.end(); it != end; ++it) {
if (!(*it)->ended())
return;
for (size_t i = 0; i < m_videoTracks.size(); ++i)
if (!m_videoTracks[i]->ended())
}
for (auto it = m_videoTracks.begin(), end = m_videoTracks.end(); it != end; ++it) {
if (!(*it)->ended())
return;
}
setEnded();
}
......@@ -351,8 +352,7 @@ void MediaStream::scheduledEventTimerFired(Timer<MediaStream>*)
Vector<RefPtr<Event>> events;
events.swap(m_scheduledEvents);
Vector<RefPtr<Event>>::iterator it = events.begin();
for (; it != events.end(); ++it)
for (auto it = events.begin(), end = events.end(); it != end; ++it)
dispatchEvent((*it).release());
events.clear();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment