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>
This commit is contained in:
Lukas Fleischer
2012-06-27 11:31:08 +02:00
parent 81d97315c7
commit 7a75415a61
4 changed files with 41 additions and 1 deletions

View File

@@ -144,6 +144,8 @@
#define DAYINSEC (DAYINMIN * MININSEC)
#define HOURINSEC (HOURINMIN * MININSEC)
#define MAXDAYSPERMONTH 31
/* Calendar window. */
#define CALHEIGHT 12
@@ -629,6 +631,7 @@ void calendar_store_current_date(struct date *);
void calendar_init_slctd_day(void);
struct date *calendar_get_slctd_day(void);
long calendar_get_slctd_day_sec(void);
void calendar_monthly_view_cache_set_invalid(void);
void calendar_update_panel(struct window *);
void calendar_goto_today(void);
void calendar_change_day(int);