summaryrefslogtreecommitdiffstats
path: root/slick.grid.js
diff options
context:
space:
mode:
authorkzhdev <kun.zhao@tradingtechnologies.com>2013-08-21 14:49:22 -0500
committerkzhdev <kun.zhao@tradingtechnologies.com>2013-08-22 14:06:30 -0500
commit34fe7426538c20942723c3aa3cf2deb29729db61 (patch)
treebe529fa517380e7f69a0d85fa2649b865aca3d43 /slick.grid.js
parent70935e0191214a64d58db80176be65ab18c0abb5 (diff)
downloadSlickGrid-34fe7426538c20942723c3aa3cf2deb29729db61.zip
SlickGrid-34fe7426538c20942723c3aa3cf2deb29729db61.tar.gz
SlickGrid-34fe7426538c20942723c3aa3cf2deb29729db61.tar.bz2
performance improvement
Conflicts: slick.grid.js
Diffstat (limited to 'slick.grid.js')
-rw-r--r--slick.grid.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/slick.grid.js b/slick.grid.js
index a401070..37ebc67 100644
--- a/slick.grid.js
+++ b/slick.grid.js
@@ -1595,7 +1595,9 @@ if (typeof Slick === "undefined") {
function updateRowCount() {
var dataLength = getDataLength();
if (!initialized) { return; }
- numberOfRows = getDataLengthIncludingAddNew() +
+
+ var dataLengthIncludingAddNew = getDataLengthIncludingAddNew();
+ var numberOfRows = dataLengthIncludingAddNew +
(options.leaveSpaceForNewRows ? numVisibleRows - 1 : 0);
var oldViewportHasVScroll = viewportHasVScroll;
@@ -1604,7 +1606,7 @@ if (typeof Slick === "undefined") {
// remove the rows that are now outside of the data range
// this helps avoid redundant calls to .removeRow() when the size of the data decreased by thousands of rows
- var l = getDataLengthIncludingAddNew() - 1;
+ var l = dataLengthIncludingAddNew - 1;
for (var i in rowsCache) {
if (i >= l) {
removeRowFromCache(i);
@@ -1997,10 +1999,11 @@ if (typeof Slick === "undefined") {
}
function asyncPostProcessRows() {
+ var dataLength = getDataLength();
while (postProcessFromRow <= postProcessToRow) {
var row = (vScrollDir >= 0) ? postProcessFromRow++ : postProcessToRow--;
var cacheEntry = rowsCache[row];
- if (!cacheEntry || row >= getDataLength()) {
+ if (!cacheEntry || row >= dataLength) {
continue;
}
@@ -2486,13 +2489,14 @@ if (typeof Slick === "undefined") {
}
function isCellPotentiallyEditable(row, cell) {
+ var dataLength = getDataLength();
// is the data for this row loaded?
- if (row < getDataLength() && !getDataItem(row)) {
+ if (row < dataLength && !getDataItem(row)) {
return false;
}
// are we in the Add New row? can we create new from this cell?
- if (columns[cell].cannotTriggerInsert && row >= getDataLength()) {
+ if (columns[cell].cannotTriggerInsert && row >= dataLength) {
return false;
}
@@ -2716,8 +2720,9 @@ if (typeof Slick === "undefined") {
if (options.enableCellNavigation && activeRow != null) {
var row = activeRow + deltaRows;
- if (row >= getDataLengthIncludingAddNew()) {
- row = getDataLengthIncludingAddNew() - 1;
+ var dataLengthIncludingAddNew = getDataLengthIncludingAddNew();
+ if (row >= dataLengthIncludingAddNew) {
+ row = dataLengthIncludingAddNew - 1;
}
if (row < 0) {
row = 0;
@@ -2839,8 +2844,9 @@ if (typeof Slick === "undefined") {
function gotoDown(row, cell, posX) {
var prevCell;
+ var dataLengthIncludingAddNew = getDataLengthIncludingAddNew();
while (true) {
- if (++row >= getDataLengthIncludingAddNew()) {
+ if (++row >= dataLengthIncludingAddNew) {
return null;
}
@@ -2901,7 +2907,8 @@ if (typeof Slick === "undefined") {
}
var firstFocusableCell = null;
- while (++row < getDataLengthIncludingAddNew()) {
+ var dataLengthIncludingAddNew = getDataLengthIncludingAddNew();
+ while (++row < dataLengthIncludingAddNew) {
firstFocusableCell = findFirstFocusableCell(row);
if (firstFocusableCell !== null) {
return {