Skip to content

Commit

Permalink
perf(calendar): Optimization of date computation when handle attendee…
Browse files Browse the repository at this point in the history
…s. Report of 77b2d9f.
  • Loading branch information
WoodySlum committed May 28, 2024
1 parent 45fd999 commit 53d77f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions SoObjects/Appointments/SOGoAppointmentObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,17 @@ - (NSException *) _handleAttendeesConflicts: (NSArray *) theAttendees
NSEnumerator *enumerator;
NSString *currentUID;
SOGoUser *user, *currentUser;
unsigned long long eventStartPeriod, eventEndPeriod;

_resourceHasAutoAccepted = NO;

// Build a list of the attendees uids
attendees = [NSMutableArray arrayWithCapacity: [theAttendees count]];
enumerator = [theAttendees objectEnumerator];

eventStartPeriod = [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtstart"] timeZone] periodForDate: [theEvent startDate]] secondsOffsetFromGMT];
eventEndPeriod = [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtend"] timeZone] periodForDate: [theEvent startDate]] secondsOffsetFromGMT];

while ((currentAttendee = [enumerator nextObject]))
{
currentUID = [currentAttendee uidInContext: context];
Expand Down Expand Up @@ -740,11 +745,11 @@ - (NSException *) _handleAttendeesConflicts: (NSArray *) theAttendees
// We MUST use the -uniqueChildWithTag method here because the event has been flattened, so its timezone has been
// modified in SOGoAppointmentFolder: -fixupCycleRecord: ....
rangeStartDate = [[fbInfo objectAtIndex: i] objectForKey: @"startDate"];
delta = [[rangeStartDate timeZoneDetail] timeZoneSecondsFromGMT] - [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtstart"] timeZone] periodForDate: [theEvent startDate]] secondsOffsetFromGMT];
delta = [[rangeStartDate timeZoneDetail] timeZoneSecondsFromGMT] - eventStartPeriod;
rangeStartDate = [rangeStartDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: delta];

rangeEndDate = [[fbInfo objectAtIndex: i] objectForKey: @"endDate"];
delta = [[rangeEndDate timeZoneDetail] timeZoneSecondsFromGMT] - [[[(iCalDateTime *)[theEvent uniqueChildWithTag: @"dtend"] timeZone] periodForDate: [theEvent endDate]] secondsOffsetFromGMT];
delta = [[rangeEndDate timeZoneDetail] timeZoneSecondsFromGMT] - eventEndPeriod;
rangeEndDate = [rangeEndDate dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: delta];

range = [NGCalendarDateRange calendarDateRangeWithStartDate: rangeStartDate
Expand Down

0 comments on commit 53d77f3

Please sign in to comment.