PlayHandle: use QList instead of QVector for PlayHandle array

Use QList instead of QVector when using a set of PlayHandle's. QList
has faster insert/remove operations and in most cases we iterate through
the array using iterators so there's no performance drop.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
(cherry picked from commit 2cc49b8010)
This commit is contained in:
Tobias Doerffel
2009-06-15 15:04:55 +02:00
parent cafb24fe9a
commit 0faaab4521
5 changed files with 26 additions and 26 deletions

View File

@@ -234,7 +234,7 @@ public:
void removePlayHandle( playHandle * _ph );
inline playHandleVector & playHandles( void )
inline PlayHandleList & playHandles( void )
{
return m_playHandles;
}
@@ -443,8 +443,8 @@ private:
QWaitCondition m_queueReadyWaitCond;
playHandleVector m_playHandles;
constPlayHandleVector m_playHandlesToRemove;
PlayHandleList m_playHandles;
ConstPlayHandleList m_playHandlesToRemove;
struct qualitySettings m_qualitySettings;
float m_masterGain;

View File

@@ -1,8 +1,8 @@
/*
* play_handle.h - base-class playHandle - core of rendering engine
*
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
*
*/
#ifndef _PLAY_HANDLE_H
#define _PLAY_HANDLE_H
@@ -98,8 +97,8 @@ private:
} ;
typedef QVector<playHandle *> playHandleVector;
typedef QVector<const playHandle *> constPlayHandleVector;
typedef QList<playHandle *> PlayHandleList;
typedef QList<const playHandle *> ConstPlayHandleList;
#endif

View File

@@ -248,7 +248,7 @@ void MixerWorkerThread::processJobQueue( void )
#define FILL_JOB_QUEUE_BEGIN(_vec_type,_vec,_condition) \
MixerWorkerThread::s_jobQueue.queueSize = 0; \
MixerWorkerThread::s_jobQueue.itemsDone = 0; \
for( _vec_type::iterator it = _vec.begin(); \
for( _vec_type::Iterator it = _vec.begin(); \
it != _vec.end(); ++it ) \
{ \
if( _condition ) \
@@ -585,10 +585,10 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
// remove all play-handles that have to be deleted and delete
// them if they still exist...
// maybe this algorithm could be optimized...
constPlayHandleVector::iterator it_rem = m_playHandlesToRemove.begin();
ConstPlayHandleList::Iterator it_rem = m_playHandlesToRemove.begin();
while( it_rem != m_playHandlesToRemove.end() )
{
playHandleVector::iterator it = qFind( m_playHandles.begin(),
PlayHandleList::Iterator it = qFind( m_playHandles.begin(),
m_playHandles.end(), *it_rem );
if( it != m_playHandles.end() )
@@ -618,14 +618,14 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
// STAGE 1: run and render all play handles
FILL_JOB_QUEUE(playHandleVector,m_playHandles,
FILL_JOB_QUEUE(PlayHandleList,m_playHandles,
MixerWorkerThread::PlayHandle,
!( *it )->done());
START_JOBS();
WAIT_FOR_JOBS();
// removed all play handles which are done
for( playHandleVector::iterator it = m_playHandles.begin();
for( PlayHandleList::Iterator it = m_playHandles.begin();
it != m_playHandles.end(); )
{
if( ( *it )->affinityMatters() &&
@@ -689,7 +689,7 @@ void mixer::clear( void )
{
// TODO: m_midiClient->noteOffAll();
lock();
for( playHandleVector::iterator it = m_playHandles.begin();
for( PlayHandleList::Iterator it = m_playHandles.begin();
it != m_playHandles.end(); ++it )
{
// we must not delete instrument-play-handles as they exist
@@ -903,7 +903,7 @@ void mixer::restoreAudioDevice( void )
void mixer::removeAudioPort( audioPort * _port )
{
QVector<audioPort *>::iterator it = qFind( m_audioPorts.begin(),
QVector<audioPort *>::Iterator it = qFind( m_audioPorts.begin(),
m_audioPorts.end(),
_port );
if( it != m_audioPorts.end() )
@@ -925,7 +925,7 @@ void mixer::removePlayHandle( playHandle * _ph )
if( _ph->affinityMatters() &&
_ph->affinity() == QThread::currentThread() )
{
playHandleVector::iterator it =
PlayHandleList::Iterator it =
qFind( m_playHandles.begin(),
m_playHandles.end(), _ph );
if( it != m_playHandles.end() )
@@ -947,7 +947,7 @@ void mixer::removePlayHandle( playHandle * _ph )
void mixer::removePlayHandles( track * _track )
{
lock();
playHandleVector::iterator it = m_playHandles.begin();
PlayHandleList::Iterator it = m_playHandles.begin();
while( it != m_playHandles.end() )
{
if( ( *it )->isFromTrack( _track ) )

View File

@@ -398,10 +398,11 @@ void notePlayHandle::mute( void )
int notePlayHandle::index( void ) const
{
const playHandleVector & phv = engine::getMixer()->playHandles();
const PlayHandleList & playHandles =
engine::getMixer()->playHandles();
int idx = 0;
for( constPlayHandleVector::ConstIterator it = phv.begin();
it != phv.end(); ++it )
for( PlayHandleList::ConstIterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );
@@ -426,11 +427,11 @@ int notePlayHandle::index( void ) const
ConstNotePlayHandleList notePlayHandle::nphsOfInstrumentTrack(
const instrumentTrack * _it, bool _all_ph )
{
const playHandleVector & phv = engine::getMixer()->playHandles();
const PlayHandleList & playHandles = engine::getMixer()->playHandles();
ConstNotePlayHandleList cnphv;
for( constPlayHandleVector::ConstIterator it = phv.begin();
it != phv.end(); ++it )
for( PlayHandleList::ConstIterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );

View File

@@ -136,9 +136,9 @@ void song::setTempo( void )
{
const bpm_t tempo = (bpm_t) m_tempoModel.value();
engine::getMixer()->lock();
playHandleVector & phv = engine::getMixer()->playHandles();
for( playHandleVector::iterator it = phv.begin(); it != phv.end();
++it )
PlayHandleList & playHandles = engine::getMixer()->playHandles();
for( PlayHandleList::Iterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
notePlayHandle * nph = dynamic_cast<notePlayHandle *>( *it );
if( nph && !nph->released() )