1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

Fix: Performance improvement for the every() methods. Rather than a new API instance being excplicitly created for every item, use the exisiting instance as the basis for the selector.

- The item selector returns a new instance, so there is no impact upon
  compatiblity
This commit is contained in:
Allan Jardine 2015-10-06 12:05:19 +01:00
parent 2d0ad42749
commit dd5ddd46a0
3 changed files with 4 additions and 3 deletions

View File

@ -1 +1 @@
936f043bb97fc0c949759064c03d24bb8fccbc05
de61014af48ec511ce3b384209f4d8c709f091a0

View File

@ -9230,6 +9230,7 @@
$.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
_api_register( type+'s().every()', function ( fn ) {
var opts = this.selector.opts;
var api = this;
return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
// Rows and columns:
@ -9243,7 +9244,7 @@
// arg3 - table counter
// arg4 - loop counter
fn.call(
new _Api( settings )[ type ](
api[ type ](
arg1,
type==='cell' ? arg2 : opts,
type==='cell' ? opts : undefined

View File

@ -133,7 +133,7 @@ function(a,e){var f=e.nScrollHead?g("table",e.nScrollHead)[0]:null,h=e.nScrollFo
c.find(a).toArray()))});g.each(["on","one","off"],function(a,b){p(b+"()",function(){var a=Array.prototype.slice.call(arguments);a[0].match(/\.dt\b/)||(a[0]+=".dt");var d=g(this.tables().nodes());d[b].apply(d,a);return this})});p("clear()",function(){return this.iterator("table",function(a){na(a)})});p("settings()",function(){return new s(this.context,this.context)});p("init()",function(){var a=this.context;return a.length?a[0].oInit:null});p("data()",function(){return this.iterator("table",function(a){return D(a.aoData,
"_aData")}).flatten()});p("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,h=b.nTHead,i=b.nTFoot,j=g(e),f=g(f),l=g(b.nTableWrapper),m=g.map(b.aoData,function(a){return a.nTr}),p;b.bDestroying=!0;w(b,"aoDestroyCallback","destroy",[b]);a||(new s(b)).columns().visible(!0);l.unbind(".DT").find(":not(tbody *)").unbind(".DT");g(Fa).unbind(".DT-"+b.sInstance);e!=h.parentNode&&(j.children("thead").detach(),j.append(h));
i&&e!=i.parentNode&&(j.children("tfoot").detach(),j.append(i));b.aaSorting=[];b.aaSortingFixed=[];xa(b);g(m).removeClass(b.asStripeClasses.join(" "));g("th, td",h).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);b.bJUI&&(g("th span."+d.sSortIcon+", td span."+d.sSortIcon,h).detach(),g("th, td",h).each(function(){var a=g("div."+d.sSortJUIWrapper,this);g(this).append(a.contents());a.detach()}));f.children().detach();f.append(m);h=a?"remove":"detach";j[h]();l[h]();
!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),j.css("width",b.sDestroyWidth).removeClass(d.sTable),(p=b.asDestroyStripes.length)&&f.children().each(function(a){g(this).addClass(b.asDestroyStripes[a%p])}));c=g.inArray(b,k.settings);-1!==c&&k.settings.splice(c,1)})});g.each(["column","row","cell"],function(a,b){p(b+"s().every()",function(a){var d=this.selector.opts;return this.iterator(b,function(e,f,h,g,j){a.call((new s(e))[b](f,"cell"===b?h:d,"cell"===b?d:l),f,h,g,j)})})});p("i18n()",function(a,
!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),j.css("width",b.sDestroyWidth).removeClass(d.sTable),(p=b.asDestroyStripes.length)&&f.children().each(function(a){g(this).addClass(b.asDestroyStripes[a%p])}));c=g.inArray(b,k.settings);-1!==c&&k.settings.splice(c,1)})});g.each(["column","row","cell"],function(a,b){p(b+"s().every()",function(a){var d=this.selector.opts,e=this;return this.iterator(b,function(f,h,g,j,k){a.call(e[b](h,"cell"===b?g:d,"cell"===b?d:l),h,g,j,k)})})});p("i18n()",function(a,
b,c){var d=this.context[0],a=P(a)(d.oLanguage);a===l&&(a=b);c!==l&&g.isPlainObject(a)&&(a=a[c]!==l?a[c]:a._);return a.replace("%d",c)});k.version="1.10.10-dev";k.settings=[];k.models={};k.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};k.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1};k.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,
_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};k.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,
bInfo:!0,bJQueryUI:!1,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===