Minor optimisation.

This commit is contained in:
Alexander Ljungberg
2012-03-25 14:15:18 +01:00
parent f50802b85b
commit da80176935
+8 -8
View File
@@ -4653,19 +4653,19 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
while (![_delegate tableView:self shouldSelectRow:i] && (i < [self numberOfRows] || i > 0))
shouldGoUpward ? i-- : i++; //check to see if the row can be selected if it can't be then see if the next row can be selected
//if the index still can be selected after the loop then just return
if (![_delegate tableView:self shouldSelectRow:i])
return;
// If the index still can be selected after the loop then just return.
if (![_delegate tableView:self shouldSelectRow:i])
return;
}
// if we go upward and see that this row is already selected we should deselect the row below
if ([selectedIndexes containsIndex:i] && extend)
// If we go upward and see that this row is already selected we should deselect the row below.
if (extend && [selectedIndexes containsIndex:i])
{
// the row we're on is the last to be selected
// The row we're on is the last to be selected.
var differedLastSelectedRow = i;
// no remove the one before/after it
shouldGoUpward ? i++ : i--;
shouldGoUpward ? i++ : i--;
[selectedIndexes removeIndex:i];
@@ -4677,7 +4677,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if ([selectedIndexes containsIndex:i])
{
i = shouldGoUpward ? [selectedIndexes firstIndex] -1 : [selectedIndexes lastIndex] + 1;
i = MIN(MAX(i,0), [self numberOfRows] - 1);
i = MIN(MAX(i, 0), [self numberOfRows] - 1);
}
[selectedIndexes addIndex:i];