Browse Source

small optimization to table (reduce calls to Container.size() method, that is expensive in some containers)

svn changeset:7564/svn branch:6.0
tags/6.7.0.beta1
Matti Tahvonen 15 years ago
parent
commit
d452ea2fd4
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      src/com/itmill/toolkit/ui/Table.java

+ 9
- 3
src/com/itmill/toolkit/ui/Table.java View File

@@ -1107,12 +1107,18 @@ public class Table extends AbstractSelect implements Action.Container,
newIndex = 0;
}

/*
* minimize Container.size() calls which may be expensive. For example
* it may cause sql query.
*/
final int size = size();

/*
* The table is not capable of displaying an item in the container as
* the first if there are not enough items following the selected item
* so the whole table (pagelength) is filled.
*/
int maxIndex = size() - pageLength;
int maxIndex = size - pageLength;
if (maxIndex < 0) {
maxIndex = 0;
}
@@ -1150,7 +1156,7 @@ public class Table extends AbstractSelect implements Action.Container,

// If we did hit the border
if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
currentPageFirstItemIndex = size() - 1;
currentPageFirstItemIndex = size - 1;
}

// Go backwards in the middle of the list (respect borders)
@@ -1179,7 +1185,7 @@ public class Table extends AbstractSelect implements Action.Container,
// If for some reason we do hit border again, override
// the user index request
if (((Container.Ordered) items).isLastId(currentPageFirstItemId)) {
newIndex = currentPageFirstItemIndex = size() - 1;
newIndex = currentPageFirstItemIndex = size - 1;
}
}
if (needsPageBufferReset) {

Loading…
Cancel
Save