From c18e7854f66d8f494a9d5254c704daeea4bc5ea2 Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 1 Apr 2013 15:10:49 +0200 Subject: [PATCH] Little moveChild() cleanup --- localmylist/mylistnode.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/localmylist/mylistnode.cpp b/localmylist/mylistnode.cpp index ddf355c..7b08182 100644 --- a/localmylist/mylistnode.cpp +++ b/localmylist/mylistnode.cpp @@ -223,8 +223,8 @@ MyListNode::MoveType MyListNode::moveChild(MyListNode *child, Operation type) return SuccessfulMove; } - auto lower = std::upper_bound(childItems.begin(), oldPos, child, compareFunction()); - auto upper = std::lower_bound(oldPos, childItems.end(), child, compareFunction()); + const auto lower = std::upper_bound(childItems.begin(), oldPos, child, compareFunction()); + const auto upper = std::lower_bound(oldPos, childItems.end(), child, compareFunction()); // No move needed if (lower == upper) @@ -232,13 +232,7 @@ MyListNode::MoveType MyListNode::moveChild(MyListNode *child, Operation type) return NoMove; } - decltype(childItems.begin()) it; - - // New pos in upper part - if (lower == oldPos) - it = upper; - else - it = lower; + const auto it = (lower == oldPos) ? upper : lower; // Added item is not in the currently loaded data if (it == childItems.end() && canFetchMore()) -- 2.52.0