Monthview is slow in sorting events

RESOLVED FIXED in 0.8

Status

RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: mvl, Assigned: mvl)

Tracking

unspecified
Bug Flags:
blocking-calendar0.8 +

Details

Attachments

(1 attachment)

The events for each day in the monthview are sorted using javascript's Array.Sort().
The array is build one item at a time. After each addition, the array is sorted. This means that an almost-sorted array is sorted using QuickSort. That's not good. (yes, this is also done when switching months. The views can't wait for all items to have arrived, due to async calendars)

Suggestion: insert the item at the right place when building the array. No need to sort.
(Assignee)

Comment 1

11 years ago
Created attachment 293571 [details] [diff] [review]
proof of concept v1

This patch is a proof-of-concept. A quick test shows that it seem to work, but I would like some more testing on it. Any volunteers? :)

The same quick test showed that it reduces the time to switch months in a pretty busy calendar was reduced by roughly 20 to 40%.
(Assignee)

Comment 2

11 years ago
Comment on attachment 293571 [details] [diff] [review]
proof of concept v1

>Index: base/content/calendar-month-view.xml
>+          this.mItemData.splice(i, 0, o);
that 'o' should be 'newItem' ofcourse.
(Assignee)

Updated

11 years ago
Attachment #293571 - Flags: review?(michael.buettner)

Updated

11 years ago
Flags: wanted-calendar0.8+

Comment 3

11 years ago
Comment on attachment 293571 [details] [diff] [review]
proof of concept v1

>+          this.mItemData.splice(i, 0, o);
>+          
>           this.relayout();
>         ]]></body>
>       </method>

You have already found the error in the first line. Could you please remove the trailings spaces in the second line as well.

Updated

11 years ago
Assignee: nobody → mvl
Flags: wanted-calendar0.8+ → blocking-calendar0.8+

Updated

11 years ago
Status: NEW → ASSIGNED
Comment on attachment 293571 [details] [diff] [review]
proof of concept v1

>+          this.mItemData.splice(i, 0, o);
>+          
See previous comments. Apart from that, no complaints, works like a charm. r=mickey.
Attachment #293571 - Flags: review?(michael.buettner) → review+
(Assignee)

Comment 5

11 years ago
patch checked in
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 0.8
Version: Trunk → unspecified

Comment 6

11 years ago
I think I see some improvement with this fix in. The months refresh a bit faster than with the nightly build performed on the 14th for 1.8 Mozilla trunk. 
You need to log in before you can comment on or make changes to this bug.