diff options
author | Max Kellermann <max@duempel.org> | 2013-01-06 23:44:59 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-06 23:48:34 +0100 |
commit | 6936c0e2abc4e50db169e5c034bd9fb4dab04d0c (patch) | |
tree | e2e1d50b6a9fd8c654fd7c6c319344f9fe33320c | |
parent | 108242042e684b9d6147aeb97351b823e0a1ed0b (diff) | |
download | mpd-6936c0e2abc4e50db169e5c034bd9fb4dab04d0c.tar.gz mpd-6936c0e2abc4e50db169e5c034bd9fb4dab04d0c.tar.xz mpd-6936c0e2abc4e50db169e5c034bd9fb4dab04d0c.zip |
Queue: use std::swap
-rw-r--r-- | src/Queue.cxx | 5 | ||||
-rw-r--r-- | src/Queue.hxx | 6 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/Queue.cxx b/src/Queue.cxx index f64bbf5c9..1b329e485 100644 --- a/src/Queue.cxx +++ b/src/Queue.cxx @@ -145,13 +145,10 @@ queue::Append(struct song *song, uint8_t priority) void queue::SwapPositions(unsigned position1, unsigned position2) { - struct queue_item tmp; unsigned id1 = items[position1].id; unsigned id2 = items[position2].id; - tmp = items[position1]; - items[position1] = items[position2]; - items[position2] = tmp; + std::swap(items[position1], items[position2]); items[position1].version = version; items[position2].version = version; diff --git a/src/Queue.hxx b/src/Queue.hxx index 501fb0564..f52dd3335 100644 --- a/src/Queue.hxx +++ b/src/Queue.hxx @@ -24,6 +24,8 @@ #include <glib.h> +#include <algorithm> + #include <assert.h> #include <stdint.h> @@ -265,9 +267,7 @@ struct queue { * Swaps two songs, addressed by their order number. */ void SwapOrders(unsigned order1, unsigned order2) { - unsigned tmp = order[order1]; - order[order1] = order[order2]; - order[order2] = tmp; + std::swap(order[order1], order[order2]); } /** |