DRYer
This commit is contained in:
parent
2ba28171ab
commit
30023d9d9c
3 changed files with 6 additions and 4 deletions
|
|
@ -89,7 +89,7 @@ grman_alloc(bool for_paused_rendering) {
|
|||
return self;
|
||||
}
|
||||
|
||||
#define iter_refs(img) for (ref_map_itr i = vt_first(&((img)->refs_by_internal_id)); !vt_is_end(i); i = vt_next(i))
|
||||
#define iter_refs(img) vt_create_for_loop(ref_map_itr, i, &((img)->refs_by_internal_id))
|
||||
|
||||
static void
|
||||
free_refs_data(Image *img) {
|
||||
|
|
@ -160,7 +160,7 @@ free_image(GraphicsManager *self, Image *img) {
|
|||
free(img);
|
||||
}
|
||||
|
||||
#define iter_images(grman) for (image_map_itr i = vt_first(&((grman)->images_by_internal_id)); !vt_is_end(i); i = vt_next(i))
|
||||
#define iter_images(grman) vt_create_for_loop(image_map_itr, i, &((grman)->images_by_internal_id))
|
||||
|
||||
static void
|
||||
free_all_images(GraphicsManager *self) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#define KEY_TY const char*
|
||||
#define VAL_TY hyperlink_id_type
|
||||
#include "kitty-verstable.h"
|
||||
#define hyperlink_for_loop vt_create_for_loop(hyperlink_map_itr, itr, &pool->map)
|
||||
|
||||
typedef const char* hyperlink;
|
||||
typedef struct HyperLinks {
|
||||
|
|
@ -167,7 +168,7 @@ screen_hyperlinks_as_set(Screen *screen) {
|
|||
HyperLinkPool *pool = (HyperLinkPool*)screen->hyperlink_pool;
|
||||
RAII_PyObject(ans, PySet_New(0));
|
||||
if (ans) {
|
||||
for (hyperlink_map_itr itr = vt_first(&pool->map); !vt_is_end(itr); itr = vt_next(itr)) {
|
||||
hyperlink_for_loop {
|
||||
RAII_PyObject(e, Py_BuildValue("sH", itr.data->key, itr.data->val));
|
||||
if (!e || PySet_Add(ans, e) != 0) return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ typedef struct WindowLogoItem {
|
|||
#define KEY_TY window_logo_id_t
|
||||
#define VAL_TY WindowLogoItem*
|
||||
#include "kitty-verstable.h"
|
||||
#define id_for_loop(table) vt_create_for_loop(hash_by_id_itr, itr, &(table)->by_id)
|
||||
|
||||
#define NAME hash_by_path
|
||||
#define KEY_TY const char*
|
||||
|
|
@ -109,7 +110,7 @@ alloc_window_logo_table(void) {
|
|||
|
||||
void
|
||||
free_window_logo_table(WindowLogoTable **table) {
|
||||
for (hash_by_id_itr itr = vt_first( &(*table)->by_id ); !vt_is_end( itr ); itr = vt_next( itr )) free_window_logo(&itr.data->val);
|
||||
id_for_loop(*table) free_window_logo(&itr.data->val);
|
||||
vt_cleanup(&(*table)->by_id); vt_cleanup(&(*table)->by_path);
|
||||
free(*table); *table = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue