Closed Bug 408727 Opened 17 years ago Closed 16 years ago

Monthview is slow in sorting events

Categories

(Calendar :: Calendar Frontend, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mvl, Assigned: mvl)

Details

Attachments

(1 file)

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.
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%.
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.
Attachment #293571 - Flags: review?(michael.buettner)
Flags: wanted-calendar0.8+
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.
Assignee: nobody → mvl
Flags: wanted-calendar0.8+ → blocking-calendar0.8+
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+
patch checked in
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Target Milestone: --- → 0.8
Version: Trunk → unspecified
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.