SwarmOnline / Ext.ux.TouchCalendar

Sencha Touch Calendar component
113 stars 47 forks source link

Very slow due to repeated unnecessary sorting #26

Open trevoriancox opened 11 years ago

trevoriancox commented 11 years ago

In TouchCalendarEventsBase.js, sort is called on eventStore repeatedly, for every date. In my test, moving sort() to before dates.each() reduced the time to display a new month in month view from 3 secs to 0.5 secs (with 300 event records, Chrome desktop browser).

dates.each(function(dateObj){
            var currentDate = dateObj.get('date'),
                currentDateTime = currentDate.getTime(),
                takenDatePositions = []; // stores 'row positions' that are taken on current date

            // sort the Events Store so we have a consistent ordering to ensure no overlaps
            eventStore.sort(this.getPlugin().getStartEventField(), this.getEventSortDirection());
trevoriancox commented 11 years ago

Also I think we should make the eventStore sort optional (skip if StartEventField is not set), as the eventStore may already be appropriately sorted.