use a list instead of a deque
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#include "RageTimer.h"
|
#include "RageTimer.h"
|
||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
|
|
||||||
#include <deque>
|
#include <list>
|
||||||
|
|
||||||
/* The number of frames we should keep pos_map data for. This being too high
|
/* The number of frames we should keep pos_map data for. This being too high
|
||||||
* is mostly harmless; the data is small. */
|
* is mostly harmless; the data is small. */
|
||||||
@@ -27,7 +27,7 @@ struct pos_map_t
|
|||||||
|
|
||||||
struct pos_map_impl
|
struct pos_map_impl
|
||||||
{
|
{
|
||||||
deque<pos_map_t> m_Queue;
|
list<pos_map_t> m_Queue;
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,18 +79,18 @@ void pos_map_queue::Insert( int64_t iSourceFrame, int iDestFrame, int iFrames )
|
|||||||
|
|
||||||
void pos_map_impl::Cleanup()
|
void pos_map_impl::Cleanup()
|
||||||
{
|
{
|
||||||
/* Determine the number of frames of data we have. */
|
/* Scan backwards until we have at least pos_map_backlog_frames. */
|
||||||
int64_t iTotalFrames = 0;
|
list<pos_map_t>::iterator it = m_Queue.end();
|
||||||
for( unsigned i = 0; i < m_Queue.size(); ++i )
|
int iTotalFrames = 0;
|
||||||
iTotalFrames += m_Queue[i].m_iFrames;
|
while( iTotalFrames < pos_map_backlog_frames )
|
||||||
|
|
||||||
/* Remove the oldest entry so long we'll stil have enough data. Don't delete every
|
|
||||||
* frame, so we'll always have some data to extrapolate from. */
|
|
||||||
while( m_Queue.size() > 1 && iTotalFrames - m_Queue.front().m_iFrames > pos_map_backlog_frames )
|
|
||||||
{
|
{
|
||||||
iTotalFrames -= m_Queue.front().m_iFrames;
|
if( it == m_Queue.begin() )
|
||||||
m_Queue.pop_front();
|
break;
|
||||||
|
--it;
|
||||||
|
iTotalFrames += it->m_iFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_Queue.erase( m_Queue.begin(), it );
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
|
int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
|
||||||
@@ -106,7 +106,7 @@ int64_t pos_map_queue::Search( int64_t iSourceFrame, bool *bApproximate ) const
|
|||||||
* it maps to. */
|
* it maps to. */
|
||||||
int64_t iClosestPosition = 0, iClosestPositionDist = INT_MAX;
|
int64_t iClosestPosition = 0, iClosestPositionDist = INT_MAX;
|
||||||
const pos_map_t *pClosestBlock = &*m_pImpl->m_Queue.begin(); /* print only */
|
const pos_map_t *pClosestBlock = &*m_pImpl->m_Queue.begin(); /* print only */
|
||||||
FOREACHD_CONST( pos_map_t, m_pImpl->m_Queue, it )
|
FOREACHL_CONST( pos_map_t, m_pImpl->m_Queue, it )
|
||||||
{
|
{
|
||||||
const pos_map_t &pm = *it;
|
const pos_map_t &pm = *it;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user