Performance Bug - deep cloning the data passed on init (DT 1.10)

Performance Bug - deep cloning the data passed on init (DT 1.10)

RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
edited May 2014 in Bug reports

The following code is the key of the problems:
https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L5930

Optimization (skip the cloning of the data that is passed as parameter):

delete oInit["data"];
delete oInit["aaData"];
/* Create the settings object for this table and set some of the default parameters */
var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
 "nTable":        this,
 "oApi":          _that.internal,
 "oInit":         oInit,
 "sDestroyWidth": $(this)[0].style.width,
 "sInstance":     sId,
 "sTableId":      sId
});
if (!!tmpData) {
 oSettings.oInit.data = tmpData;
 oInit.data = tmpData;
}
if (!!tmpaaData) {
 oSettings.oInit.aaData = tmpaaData;
 oInit.aaData = tmpaaData;
}

this will perform way faster that the original one when having thousands of rows with nested data.

Example:
On my machine it takes 5 second to render because of the deep cloning:
http://live.datatables.net/vekawik/2/

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Nice one. Thanks for letting me know about that. I'll make sure something to fix this is in for 1.10.1.

    Allan

This discussion has been closed.