From 5c279839005d2218319fa5546b6e498df753e68e Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 6 Sep 2000 09:59:17 +0000 Subject: Use new convenience functions and only get the recurrence stuff if needed. 2000-09-06 JP Rosevear * cal-util/cal-recur.c (cal_recur_generate_instances): Use new convenience functions and only get the recurrence stuff if needed. Free the recurrence stuff if used. 2000-09-05 JP Rosevear * cal-util/cal-component.h: Add new prototypes * cal-util/cal-component.c (cal_component_has_exrules): Utility function to determine whether a cal component has any exrules (cal_component_has_exdates): Ditto for exdates (cal_component_has_exceptions): Utility function to determine whether a cal component has any exception rules (cal_component_has_recurrences):Utility function to determine whether a cal component has any recurrence rules svn path=/trunk/; revision=5219 --- calendar/cal-util/cal-recur.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'calendar/cal-util/cal-recur.c') diff --git a/calendar/cal-util/cal-recur.c b/calendar/cal-util/cal-recur.c index 49bf9a9a08..648e5293e9 100644 --- a/calendar/cal-util/cal-recur.c +++ b/calendar/cal-util/cal-recur.c @@ -489,16 +489,10 @@ cal_recur_generate_instances (CalComponent *comp, else dtend_time = time_day_end (dtstart_time); - - cal_component_get_rrule_list (comp, &rrules); - cal_component_get_rdate_list (comp, &rdates); - cal_component_get_exrule_list (comp, &exrules); - cal_component_get_exdate_list (comp, &exdates); - /* If there is no recurrence, just call the callback if the event intersects the given interval. */ - - if (!(rrules || rdates || exrules || exdates)) { + if (!(cal_component_has_recurrences (comp) + || cal_component_has_exceptions (comp))) { if ((end && dtstart_time < end && dtend_time > start) || (end == 0 && dtend_time > start)) { (* cb) (comp, dtstart_time, dtend_time, cb_data); @@ -507,6 +501,12 @@ cal_recur_generate_instances (CalComponent *comp, goto out; } + /* Get the recurrence rules */ + cal_component_get_rrule_list (comp, &rrules); + cal_component_get_rdate_list (comp, &rdates); + cal_component_get_exrule_list (comp, &exrules); + cal_component_get_exdate_list (comp, &exdates); + /* Convert the interval start & end to CalObjTime. */ cal_object_time_from_time (&interval_start, start); cal_object_time_from_time (&interval_end, end); @@ -558,6 +558,12 @@ cal_recur_generate_instances (CalComponent *comp, break; } + cal_component_free_recur_list (rrules); + cal_component_free_period_list (rdates); + cal_component_free_recur_list (exrules); + cal_component_free_exdate_list (exdates); + + out: cal_component_free_datetime (&dtstart); cal_component_free_datetime (&dtend); -- cgit v1.2.3