Index: trunk/src/obj_pstk.h =================================================================== --- trunk/src/obj_pstk.h (revision 19223) +++ trunk/src/obj_pstk.h (revision 19224) @@ -76,6 +76,7 @@ /* local cache - not saved */ unsigned long hash; /* optimization: linear search compare speeded up: go into detailed match only if hash matches */ pcb_data_t *parent; + int mech_idx; /* -1 or index to the first shape[] that is of PCB_LYT_MECH */ } pcb_pstk_proto_t; @@ -217,6 +218,8 @@ copied into data. In any case, the caller should not free proto. */ pcb_cardinal_t pcb_pstk_proto_insert_or_free(pcb_data_t *data, pcb_pstk_proto_t *proto, int quiet); +/* Update caches and hash - must be called after any change to the prototype */ +void pcb_pstk_proto_update(pcb_pstk_proto_t *dst); /*** hash ***/ unsigned int pcb_pstk_proto_hash(const pcb_pstk_proto_t *p); Index: trunk/src/obj_pstk_proto.c =================================================================== --- trunk/src/obj_pstk_proto.c (revision 19223) +++ trunk/src/obj_pstk_proto.c (revision 19224) @@ -49,6 +49,11 @@ #warning TODO: do a full field free here } +void pcb_pstk_proto_update(pcb_pstk_proto_t *dst) +{ + dst->hash = pcb_pstk_proto_hash(dst); +} + void pcb_pstk_shape_alloc_poly(pcb_pstk_poly_t *poly, int len) { poly->x = malloc(sizeof(poly->x[0]) * len * 2); @@ -278,7 +283,7 @@ } /* all went fine */ - dst->hash = pcb_pstk_proto_hash(dst); + pcb_pstk_proto_update(dst); ret = 0; quit:; @@ -589,11 +594,13 @@ pcb_vtpadstack_proto_append(&data->ps_protos, *proto); np = pcb_vtpadstack_proto_get(&data->ps_protos, n, 0); np->parent = data; + pcb_pstk_proto_update(np); } else { memcpy(data->ps_protos.array+first_free, proto, sizeof(pcb_pstk_proto_t)); data->ps_protos.array[first_free].in_use = 1; data->ps_protos.array[first_free].parent = data; + pcb_pstk_proto_update(data->ps_protos.array+first_free); } memset(proto, 0, sizeof(pcb_pstk_proto_t)); /* make sure a subsequent free() won't do any harm */ return n; @@ -614,11 +621,13 @@ nproto = pcb_vtpadstack_proto_alloc_append(&data->ps_protos, 1); pcb_pstk_proto_copy(nproto, proto); nproto->parent = data; + pcb_pstk_proto_update(nproto); } else { pcb_pstk_proto_copy(data->ps_protos.array+first_free, proto); data->ps_protos.array[first_free].in_use = 1; data->ps_protos.array[first_free].parent = data; + pcb_pstk_proto_update(data->ps_protos.array+first_free); } return n; } @@ -897,6 +906,7 @@ for(n = 0; n < proto->tr.used; n++) for(i = 0; i < proto->tr.array[n].len; i++) pcb_pstk_shape_grow(&proto->tr.array[n].shape[i], is_absolute, val); + pcb_pstk_proto_update(proto); } void pcb_pstk_shape_derive(pcb_pstk_proto_t *proto, int dst_idx, int src_idx, pcb_coord_t bloat, pcb_layer_type_t mask, pcb_layer_combining_t comb) @@ -920,6 +930,7 @@ if (bloat != 0) pcb_pstk_shape_grow(&proto->tr.array[n].shape[d], pcb_false, bloat); } + pcb_pstk_proto_update(proto); } @@ -941,6 +952,8 @@ /* delete the shape from all transformed variants */ for(n = 0; n < proto->tr.used; n++) pcb_pstk_tshape_del_idx(&proto->tr.array[n], idx); + + pcb_pstk_proto_update(proto); } void pcb_pstk_proto_del_shape(pcb_pstk_proto_t *proto, pcb_layer_type_t lyt, pcb_layer_combining_t comb)