From bf9516d16438754524af22aac119f6973057700e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 3 Jan 2022 12:12:23 +0800 Subject: [PATCH] Simplify code This version saves an `if` conditional. --- src/gui/addnewtorrentdialog.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 88faf8c47..ed2ad1471 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -153,11 +153,10 @@ namespace auto pathList = settings()->loadValue(settingsKey); const int selectedSavePathIndex = pathList.indexOf(path); - if (selectedSavePathIndex > 0) - pathList.removeAt(selectedSavePathIndex); - if (selectedSavePathIndex != 0) + if (selectedSavePathIndex > -1) + pathList.move(selectedSavePathIndex, 0); + else pathList.prepend(path); - settings()->storeValue(settingsKey, QStringList(pathList.mid(0, maxLength))); } }