From 7a75415a619bd6698f45ec24f696f7b9dbb3752c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 27 Jun 2012 11:31:08 +0200 Subject: Implement a cache for the monthly view Add a very simple cache, which is used to store the days that contain an event or an appointment. This makes redrawing and browsing the calendar panel much faster. The cache has a size of 31 integers (which is equivalent to 124 bytes on a 32 bit system and 248 bytes on a 64 bit system) and invalidates itself if the current month has changed. If an item is added/changed/removed, the cache needs to be invalidated manually by calling calendar_monthly_view_cache_set_invalid(). Note that this will always invalidate the whole cache, even if only one item at the last day of the month was removed. This is a trade-off between simplicity and efficiency. Signed-off-by: Lukas Fleischer --- src/interaction.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/interaction.c') diff --git a/src/interaction.c b/src/interaction.c index 8f3ffdb..829e778 100644 --- a/src/interaction.c +++ b/src/interaction.c @@ -358,6 +358,8 @@ void interact_day_item_edit(void) break; } + calendar_monthly_view_cache_set_invalid(); + if (need_check_notify) notify_check_next_app(1); } @@ -571,6 +573,9 @@ void interact_day_item_add(void) if (apoint_hilt() == 0) apoint_hilt_increase(1); } + + calendar_monthly_view_cache_set_invalid(); + wins_erase_status_bar(); } @@ -613,6 +618,8 @@ void interact_day_item_delete(unsigned *nb_events, unsigned *nb_apoints) /* NOTREACHED */ } + calendar_monthly_view_cache_set_invalid(); + if (apoint_hilt() > 1) apoint_hilt_decrease(1); if (apad.first_onscreen >= to_be_removed) @@ -858,6 +865,8 @@ void interact_day_item_repeat(void) /* NOTREACHED */ } day_erase_item(date, item_nb, ERASE_FORCE); + + calendar_monthly_view_cache_set_invalid(); } /* Free the current cut item, if any. */ @@ -897,6 +906,8 @@ void interact_day_item_cut(unsigned *nb_events, unsigned *nb_apoints) day_cut.type = p->type; day_cut.item = p->item; + calendar_monthly_view_cache_set_invalid(); + if (p->type == EVNT || p->type == RECUR_EVNT) { (*nb_events)--; to_be_removed = 1; @@ -926,6 +937,8 @@ void interact_day_item_paste(unsigned *nb_events, unsigned *nb_apoints) item_type = day_paste_item(&day_cut, calendar_get_slctd_day_sec()); day_cut.type = 0; + calendar_monthly_view_cache_set_invalid(); + if (item_type == EVNT || item_type == RECUR_EVNT) (*nb_events)++; else if (item_type == APPT || item_type == RECUR_APPT) -- cgit v1.2.3-54-g00ecf