Index: write.c =================================================================== --- write.c (revision 31132) +++ write.c (revision 31133) @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include #include "config.h" @@ -73,6 +76,7 @@ static int io_lihata_full_tree = 0; static int wrver; static htip_t id2pxm; +static htpi_t pxm2id; static lht_node_t *build_data(pcb_data_t *data); @@ -503,7 +507,12 @@ static long gfx_invent_pxm_id(pcb_gfx_t *gfx) { rnd_pixmap_t *existing; + long int id; + id = htpi_get(&pxm2id, gfx->pxm_neutral); + if (id > 0) /* already have this pixmap stored with an id, reuse that to avoid redundant storage */ + return gfx->pxm_id = id; + if (gfx->pxm_id == 0) gfx->pxm_id = pcb_create_ID_get(); existing = htip_get(&id2pxm, gfx->pxm_id); @@ -512,6 +521,7 @@ gfx->pxm_id = pcb_create_ID_get(); htip_set(&id2pxm, gfx->pxm_id, gfx->pxm_neutral); + htip_set(&pxm2id, gfx->pxm_neutral, gfx->pxm_id); return gfx->pxm_id; } @@ -538,11 +548,13 @@ static void pxm_init(void) { htip_init(&id2pxm, longhash, longkeyeq); + htpi_init(&pxm2id, ptrhash, ptrkeyeq); } static void pxm_uninit(void) { htip_uninit(&id2pxm); + htpi_uninit(&pxm2id); }