1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

Dev: Update: _fnNodeToDataIndex can be made _so_ much faster with the new _DT_RowIndex prviate parameter - so this commit does so :-)

This commit is contained in:
Allan Jardine 2012-01-20 21:58:17 +00:00
parent 4812d1d35b
commit ea9ebaa593
2 changed files with 8 additions and 50 deletions

View File

@ -661,35 +661,14 @@
/**
* Take a TR element and convert it to an index in aoData
* @param {object} s dataTables settings object
* @param {object} oSettings dataTables settings object
* @param {node} n the TR element to find
* @returns {int} index if found, null if not
* @returns {int} index if the node is found, null if not
* @memberof DataTable#oApi
*/
function _fnNodeToDataIndex( s, n )
function _fnNodeToDataIndex( oSettings, n )
{
var i, iLen;
/* Optimisation - see if the nodes which are currently visible match, since that is
* the most likely node to be asked for (a selector or event for example)
*/
for ( i=s._iDisplayStart, iLen=s._iDisplayEnd ; i<iLen ; i++ )
{
if ( s.aoData[ s.aiDisplay[i] ].nTr == n )
{
return s.aiDisplay[i];
}
}
/* Otherwise we are in for a slog through the whole data cache */
for ( i=0, iLen=s.aoData.length ; i<iLen ; i++ )
{
if ( s.aoData[i].nTr == n )
{
return i;
}
}
return null;
return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
}

View File

@ -236,35 +236,14 @@ function _fnGatherData( oSettings )
/**
* Take a TR element and convert it to an index in aoData
* @param {object} s dataTables settings object
* @param {object} oSettings dataTables settings object
* @param {node} n the TR element to find
* @returns {int} index if found, null if not
* @returns {int} index if the node is found, null if not
* @memberof DataTable#oApi
*/
function _fnNodeToDataIndex( s, n )
function _fnNodeToDataIndex( oSettings, n )
{
var i, iLen;
/* Optimisation - see if the nodes which are currently visible match, since that is
* the most likely node to be asked for (a selector or event for example)
*/
for ( i=s._iDisplayStart, iLen=s._iDisplayEnd ; i<iLen ; i++ )
{
if ( s.aoData[ s.aiDisplay[i] ].nTr == n )
{
return s.aiDisplay[i];
}
}
/* Otherwise we are in for a slog through the whole data cache */
for ( i=0, iLen=s.aoData.length ; i<iLen ; i++ )
{
if ( s.aoData[i].nTr == n )
{
return i;
}
}
return null;
return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
}