command/QueueCommands: eliminate id lookup from handle_addid()

Use MoveRange() instead of MoveId().
This commit is contained in:
Max Kellermann 2021-10-07 22:43:26 +02:00
parent c47a858d15
commit e63ecd81ec

View File

@ -127,9 +127,9 @@ handle_addid(Client &client, Request args, Response &r)
int to = -1;
if (args.size > 1) {
const auto queue_length = partition.playlist.queue.GetLength();
if (args.size > 1) {
const char *const s = args[1];
if (*s == '+') {
/* after the current song */
@ -155,11 +155,13 @@ handle_addid(Client &client, Request args, Response &r)
}
const SongLoader loader(client);
unsigned added_id = partition.AppendURI(loader, uri);
const unsigned added_position = queue_length;
const unsigned added_id = partition.AppendURI(loader, uri);
if (to >= 0) {
try {
partition.MoveId(added_id, to);
partition.MoveRange(RangeArg::Single(added_position),
to);
} catch (...) {
/* rollback */
partition.DeleteId(added_id);