JTAppleCalendar icon indicating copy to clipboard operation
JTAppleCalendar copied to clipboard

Performance issue in -setMinMaxDate

Open mrylmz opened this issue 4 years ago • 3 comments

Version Number: 8.0.3

Description

Selecting big ranges of dates around 2-3 years in range is causing performance penalties when finishing the selection due to sorting of big selected cell collections.

Parts of the call stack:

2.94 s   96.6%	0 s	 	                           JTACMonthView.selectDates(from:to:triggerSelectionDelegate:keepSelectionIfMultiSelectionAllowed:)
2.90 s   95.2%	0 s	 	                            JTACMonthView.selectDates(_:triggerSelectionDelegate:keepSelectionIfMultiSelectionAllowed:)
1.64 s   53.9%	0 s	 	                             JTACMonthView.handleSelectionValueChanged(_:action:indexPath:selectionType:shouldTriggerSelectionDelegate:)
1.52 s   49.8%	0 s	 	                              JTACMonthView.setMinMaxDate()
1.48 s   48.6%	0 s	 	                               specialized Sequence<>.sorted()

Steps To Reproduce

Select a big range of dates that at least contain 3-4 years of data

Expected Behavior

Date selection should not block the interface responsiveness.

Additional Context

Why are all selected cells cached in JTACMonthView.selectedCellData? It should be possible to infer the selected state of cells in between two dates by just checking if the start and end date range contains a given date.

mrylmz avatar Oct 06 '21 10:10 mrylmz

Does the issue mentioned here help? https://github.com/patchthecode/JTAppleCalendar/issues/1201

patchthecode avatar Oct 14 '21 18:10 patchthecode

I need to check if it will resolve the issue. But back to the original question is there a reason why we are holding the dictionary with all the values in it? Because if there is no dependency to other related features we could do some major performance improvement in the library.

mrylmz avatar Oct 14 '21 19:10 mrylmz

Yes, I believe that I am using it. In order to tell you how, I'll have to do a look at it again. I'm a little tied up on another project, but i'll get back to this shortly.

patchthecode avatar Oct 14 '21 20:10 patchthecode