diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-04-29 08:55:45 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-04-29 08:55:45 +0000 |
commit | d452ea2fd4a476157e841cce1d232398727c4f18 (patch) | |
tree | 887cbd22cfc306a3d809f0ceab58601439e23caa /src | |
parent | 10de4fcca895564cbaeeae2753ff9c862c003126 (diff) | |
download | vaadin-framework-d452ea2fd4a476157e841cce1d232398727c4f18.tar.gz vaadin-framework-d452ea2fd4a476157e841cce1d232398727c4f18.zip |
small optimization to table (reduce calls to Container.size() method, that is expensive in some containers)
svn changeset:7564/svn branch:6.0
Diffstat (limited to 'src')
-rw-r--r-- | src/com/itmill/toolkit/ui/Table.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 083b393aa8..7ff6d53700 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -1108,11 +1108,17 @@ public class Table extends AbstractSelect implements Action.Container, } /* + * 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) { |