Mail Archives: geda-user/2015/06/27/06:14:14
On 2015-06-26 00:30, Gabriel Paubert (paubert AT iram DOT es) wrote:
> I've not changed any internal API at all yet. For now the patches in
> this area boil down to these modifications in the structure
> definitions:
>
>
> diff --git a/src/polyarea.h b/src/polyarea.h
> index 43fd93d..f63e83d 100644
> --- a/src/polyarea.h
> +++ b/src/polyarea.h
> @@ -82,8 +82,8 @@ struct VNODE
> {
> VNODE *next, *prev, *shared;
> struct {
> - unsigned int status:3;
> - unsigned int mark:1;
> + unsigned char status;
> + unsigned char mark;
> } Flags;
> CVCList *cvc_prev;
> CVCList *cvc_next;
> @@ -96,15 +96,15 @@ struct PLINE
> Coord xmin, ymin, xmax, ymax;
> PLINE *next;
> VNODE head;
> - unsigned int Count;
> double area;
> rtree_t *tree;
> - bool is_round;
> Coord cx, cy;
> Coord radius;
> + unsigned int Count;
> + bool is_round;
> struct {
> - unsigned int status:3;
> - unsigned int orient:1;
> + unsigned char status;
> + unsigned char orient;
> } Flags;
> };
>
> The reasons are:
> - when the structure size is at least a multiple of 4 bytes (32 bit),
> and more likely 8 (64 bit machines and some 32 bit because there is
> a double in there), it is stupid to use 2 bit fields when two
> unsigned char fields will do (extracting from bit fields and
> especially assigning to is more expensive).
Granted.. bitfields are ugly here. I didn't realise we used them.
> - the is_round field in the middle of PLINE is very wasteful for
> alignment.
I put that there.. next to the coordinates (to be close to the variables
it makes sense with).
Great to move these, and with our piecewise linear circular circular
approximations, we do get a lot of VNODEs.
I would, however, be surprised if this makes any measurable difference
in speed, but I might be wrong.
> I'm not sure for the area field , IIRC the alignment of doubles depends
> on the ABI for 32 bit architectures and anyway 64 bit is what really
> matters
> these days.
Agreed.
Let me know if your shorted sliver cases is fixed by any (combination)
of my patches. I suspect they will.
Best wishes,
Peter
- Raw text -