diff options
author | Max Kellermann <max@duempel.org> | 2013-01-08 16:11:25 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-08 16:11:25 +0100 |
commit | 6c57047362ce8ae26b3d468d85bbdf2516e521a5 (patch) | |
tree | eb011c34c8d0287b8139be00db2ffaa107ed9920 /src/Queue.hxx | |
parent | e29bc6912b263251675c16b7689c3919ffe51f5a (diff) | |
download | mpd-6c57047362ce8ae26b3d468d85bbdf2516e521a5.tar.gz mpd-6c57047362ce8ae26b3d468d85bbdf2516e521a5.tar.xz mpd-6c57047362ce8ae26b3d468d85bbdf2516e521a5.zip |
Queue: move code to new class IdTable
Diffstat (limited to '')
-rw-r--r-- | src/Queue.hxx | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/Queue.hxx b/src/Queue.hxx index a453ddcf1..6e7786bcd 100644 --- a/src/Queue.hxx +++ b/src/Queue.hxx @@ -21,6 +21,7 @@ #define MPD_QUEUE_HXX #include "gcc.h" +#include "IdTable.hxx" #include "util/LazyRandomEngine.hxx" #include <algorithm> @@ -82,7 +83,7 @@ struct queue { unsigned *order; /** map song ids to positions */ - int *id_to_position; + IdTable id_table; /** repeat playback when the end of the queue has been reached? */ @@ -148,13 +149,7 @@ struct queue { } int IdToPosition(unsigned id) const { - if (id >= max_length * HASH_MULT) - return -1; - - assert(id_to_position[id] >= -1); - assert(id_to_position[id] < (int)length); - - return id_to_position[id]; + return id_table.IdToPosition(id); } int PositionToId(unsigned position) const @@ -344,8 +339,6 @@ struct queue { uint8_t priority, int after_order); private: - unsigned GenerateId() const; - /** * Moves a song to a new position in the "order" list. */ @@ -356,7 +349,7 @@ private: items[to] = items[from]; items[to].version = version; - id_to_position[from_id] = to; + id_table.Move(from_id, to); } /** |