Commit 4efa5d52 authored by luyikei's avatar luyikei

MarkerManager: Use QSet instead of QList

On second thought, QSet is faster although it only makes a little difference in this case..
parent 43bcf0b5
...@@ -43,22 +43,21 @@ MarkerManager::addMarker( quint64 pos ) ...@@ -43,22 +43,21 @@ MarkerManager::addMarker( quint64 pos )
void void
MarkerManager::moveMarker( quint64 from, quint64 to ) MarkerManager::moveMarker( quint64 from, quint64 to )
{ {
for ( int i = 0; i < m_markers.size(); ++i ) auto it = m_markers.find( from );
if ( it != m_markers.end() )
{ {
if ( m_markers[i] == from ) m_markers.erase( it );
{ m_markers << to;
m_markers[i] = to;
emit markerMoved( from, to ); emit markerMoved( from, to );
return; return;
} }
}
vlmcCritical() << "Marker at" << from << "doesn't exist."; vlmcCritical() << "Marker at" << from << "doesn't exist.";
} }
void void
MarkerManager::removeMarker( quint64 pos ) MarkerManager::removeMarker( quint64 pos )
{ {
bool ret = m_markers.removeOne( pos ); bool ret = m_markers.remove( pos );
if ( ret == true ) if ( ret == true )
emit markerRemoved( pos ); emit markerRemoved( pos );
else else
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define MARKERMANAGER_H #define MARKERMANAGER_H
#include <QObject> #include <QObject>
#include <QList> #include <QSet>
#include <QVariant> #include <QVariant>
class MarkerManager : public QObject class MarkerManager : public QObject
...@@ -46,7 +46,7 @@ signals: ...@@ -46,7 +46,7 @@ signals:
void markerRemoved( quint64 pos ); void markerRemoved( quint64 pos );
private: private:
QList<quint64> m_markers; QSet<quint64> m_markers;
}; };
#endif // MARKERMANAGER_H #endif // MARKERMANAGER_H
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