Krolyxon
Commit 0639047

Branches

Refs →

nsxiv0639047

allow configuring imlib2's cache size (#171)

by default imlib2 uses a 4mb cache, which is quite small. this allows
users who have more memory to spare to set a bigger cache size and avoid
reloading an already viewed image if it fits into the cache.
Author
N-R-K
Date
2021-11-26 03:04 +0600
Committer
NRK · 2021-11-26 03:09 +0600
Parent
4396031
Commit
0639047dde5d3ccb35f9c1a7be3266a373945b6e

+7 −0

2 files changed

  1. M config.def.h +6 −0
  2. M image.c +1 −0
M config.def.h View
@@ -59,6 +59,12 @@ static const bool ANTI_ALIAS = true;
5959 */
6060 static const bool ALPHA_LAYER = false;
6161
62+/* cache size for imlib2, in bytes. For backwards compatibility reasons, the
63+ * size is kept at 4MiB. For most users, it is advised to pick a value close to
64+ * or above 128MiB for better image (re)loading performance.
65+ */
66+static const int CACHE_SIZE = 4 * 1024 * 1024; /* 4MiB */
67+
6268 #endif
6369 #ifdef _THUMBS_CONFIG
6470
M image.c View
@@ -48,6 +48,7 @@ void img_init(img_t *img, win_t *win)
4848 imlib_context_set_display(win->env.dpy);
4949 imlib_context_set_visual(win->env.vis);
5050 imlib_context_set_colormap(win->env.cmap);
51+ imlib_set_cache_size(CACHE_SIZE);
5152
5253 img->im = NULL;
5354 img->win = win;