From affc46500093cdc707a5cdbc7322e2f26df682d5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Oct 2009 01:36:05 +0200 Subject: [PATCH] mpdclient: optimize crop with delete_range MPD 0.16 supports "delete" with a range. --- src/mpdclient.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mpdclient.c b/src/mpdclient.c index 554e564..97cf78b 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -284,9 +284,15 @@ mpdclient_cmd_crop(struct mpdclient *c) mpd_command_list_begin(connection, false); - while (--length >= 0) - if (length != current) - mpd_send_delete(connection, length); + if (mpd_connection_cmp_server_version(connection, 0, 16, 0) >= 0) { + if (current < length - 1) + mpd_send_delete_range(connection, current + 1, length); + if (current > 0) + mpd_send_delete_range(connection, 0, current); + } else + while (--length >= 0) + if (length != current) + mpd_send_delete(connection, length); mpd_command_list_end(connection); -- 2.30.2