diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-27 11:31:08 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-30 14:34:36 +0200 |
commit | 7a75415a619bd6698f45ec24f696f7b9dbb3752c (patch) | |
tree | 90a8c32c6def32e16e2454cb39e8b857dabe1062 /src/interaction.c | |
parent | 81d97315c7dad26edf1dcfba849d57c3299e0f6b (diff) | |
download | calcurse-7a75415a619bd6698f45ec24f696f7b9dbb3752c.zip |
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'src/interaction.c')
-rw-r--r-- | src/interaction.c | 13 |
1 files changed, 13 insertions, 0 deletions
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) |