Commit 4efa5d52 by 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,14 +43,13 @@ MarkerManager::addMarker( quint64 pos )
void
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[i] = to;
emit markerMoved( from, to );
return;
}
m_markers.erase( it );
m_markers << to;
emit markerMoved( from, to );
return;
}
vlmcCritical() << "Marker at" << from << "doesn't exist.";
}
......@@ -58,7 +57,7 @@ MarkerManager::moveMarker( quint64 from, quint64 to )
void
MarkerManager::removeMarker( quint64 pos )
{
bool ret = m_markers.removeOne( pos );
bool ret = m_markers.remove( pos );
if ( ret == true )
emit markerRemoved( pos );
else
......
......@@ -24,7 +24,7 @@
#define MARKERMANAGER_H
#include <QObject>
#include <QList>
#include <QSet>
#include <QVariant>
class MarkerManager : public QObject
......@@ -46,7 +46,7 @@ signals:
void markerRemoved( quint64 pos );
private:
QList<quint64> m_markers;
QSet<quint64> m_markers;
};
#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 sign in to comment