Changing and fixing some stuff
- QHash is better to use than QMap in MemoryManager: faster lookups, able to reserve memory in advance - Also: reserve memory in advance for the QVector and QHash, so we don't get needles allocs for them - No need to do cleanup for the nph manager, as it uses the generic manager for allocs, and that already gets cleaned up
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include <new>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include "MemoryHelper.h"
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ struct PtrInfo
|
||||
};
|
||||
|
||||
typedef QVector<MemoryPool> MemoryPoolVector;
|
||||
typedef QMap<void*, PtrInfo> PointerInfoMap;
|
||||
typedef QHash<void*, PtrInfo> PointerInfoMap;
|
||||
|
||||
class MemoryManager
|
||||
{
|
||||
|
||||
@@ -330,7 +330,6 @@ public:
|
||||
NotePlayHandle::Origin origin = NotePlayHandle::OriginPattern );
|
||||
static void release( NotePlayHandle * nph );
|
||||
static void extend( int i );
|
||||
static void cleanup();
|
||||
|
||||
private:
|
||||
static NotePlayHandleList s_nphCache;
|
||||
|
||||
@@ -37,6 +37,8 @@ QMutex MemoryManager::s_pointerMutex;
|
||||
|
||||
bool MemoryManager::init()
|
||||
{
|
||||
s_memoryPools.reserve( 64 );
|
||||
s_pointerInfo.reserve( 4096 );
|
||||
// construct first MemoryPool and allocate memory
|
||||
MemoryPool m ( MM_INITIAL_CHUNKS );
|
||||
m.m_pool = MemoryHelper::alignedMalloc( MM_INITIAL_CHUNKS * MM_CHUNK_SIZE );
|
||||
|
||||
@@ -612,12 +612,3 @@ void NotePlayHandleManager::extend( int i )
|
||||
}
|
||||
s_mutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void NotePlayHandleManager::cleanup()
|
||||
{
|
||||
foreach( NotePlayHandle * n, s_nphCache )
|
||||
{
|
||||
delete n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,6 @@ int main( int argc, char * * argv )
|
||||
|
||||
// cleanup memory managers
|
||||
MemoryManager::cleanup();
|
||||
NotePlayHandleManager::cleanup();
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user