]> Some of my projects - localmylist.git/commitdiff
Little moveChild() cleanup
authorAPTX <marek321@gmail.com>
Mon, 1 Apr 2013 13:10:49 +0000 (15:10 +0200)
committerAPTX <marek321@gmail.com>
Mon, 1 Apr 2013 13:10:49 +0000 (15:10 +0200)
localmylist/mylistnode.cpp

index ddf355cb0f8da31b84fab008d8230892923e427c..7b08182caa12415d101e7cec87edbfc4fee3a48b 100644 (file)
@@ -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())