[postgis-tickets] r17407 - Reorder LWGEOM struct members to minimize extra padding
Raul
raul at rmr.ninja
Mon Apr 22 05:09:06 PDT 2019
Author: algunenano
Date: 2019-04-22 05:09:06 -0700 (Mon, 22 Apr 2019)
New Revision: 17407
Modified:
trunk/NEWS
trunk/liblwgeom/liblwgeom.h.in
Log:
Reorder LWGEOM struct members to minimize extra padding
Closes https://github.com/postgis/postgis/pull/390
References #4368
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-04-22 10:54:29 UTC (rev 17406)
+++ trunk/NEWS 2019-04-22 12:09:06 UTC (rev 17407)
@@ -93,6 +93,7 @@
(Darafei Praliaskouski)
- #4378, Allow passing TINs as input to GEOS-backed functions (Darafei
Praliaskouski)
+ - #4368, Reorder LWGEOM struct members to minimize extra padding (Raúl Marín)
PostGIS 2.5.0
2018/09/23
Modified: trunk/liblwgeom/liblwgeom.h.in
===================================================================
--- trunk/liblwgeom/liblwgeom.h.in 2019-04-22 10:54:29 UTC (rev 17406)
+++ trunk/liblwgeom/liblwgeom.h.in 2019-04-22 12:09:06 UTC (rev 17407)
@@ -407,11 +407,12 @@
*/
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- void *data;
+ GBOX *bbox;
+ void *data;
+ int32_t srid;
+ uint8_t type;
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
}
LWGEOM;
@@ -418,11 +419,12 @@
/* POINTYPE */
typedef struct
{
- uint8_t type; /* POINTTYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
+ GBOX *bbox;
+ POINTARRAY *point; /* hide 2d/3d (this will be an array of 1 point) */
+ int32_t srid;
+ uint8_t type; /* POINTTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
}
LWPOINT; /* "light-weight point" */
@@ -429,11 +431,12 @@
/* LINETYPE */
typedef struct
{
- uint8_t type; /* LINETYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- POINTARRAY *points; /* array of POINT3D */
+ GBOX *bbox;
+ POINTARRAY *points; /* array of POINT3D */
+ int32_t srid;
+ uint8_t type; /* LINETYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
}
LWLINE; /* "light-weight line" */
@@ -440,11 +443,12 @@
/* TRIANGLE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- POINTARRAY *points;
+ GBOX *bbox;
+ POINTARRAY *points;
+ int32_t srid;
+ uint8_t type;
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
}
LWTRIANGLE;
@@ -451,11 +455,12 @@
/* CIRCSTRINGTYPE */
typedef struct
{
- uint8_t type; /* CIRCSTRINGTYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- POINTARRAY *points; /* array of POINT(3D/3DM) */
+ GBOX *bbox;
+ POINTARRAY *points; /* array of POINT(3D/3DM) */
+ int32_t srid;
+ uint8_t type; /* CIRCSTRINGTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
}
LWCIRCSTRING; /* "light-weight circularstring" */
@@ -462,13 +467,14 @@
/* POLYGONTYPE */
typedef struct
{
- uint8_t type; /* POLYGONTYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t nrings; /* how many rings we are currently storing */
- uint32_t maxrings; /* how many rings we have space for in **rings */
- POINTARRAY **rings; /* list of rings (list of points) */
+ GBOX *bbox;
+ POINTARRAY **rings; /* list of rings (list of points) */
+ int32_t srid;
+ uint8_t type; /* POLYGONTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t nrings; /* how many rings we are currently storing */
+ uint32_t maxrings; /* how many rings we have space for in **rings */
}
LWPOLY; /* "light-weight polygon" */
@@ -475,13 +481,14 @@
/* MULTIPOINTTYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWPOINT **geoms;
+ GBOX *bbox;
+ LWPOINT **geoms;
+ int32_t srid;
+ uint8_t type; /* MULTYPOINTTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWMPOINT;
@@ -488,13 +495,14 @@
/* MULTILINETYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWLINE **geoms;
+ GBOX *bbox;
+ LWLINE **geoms;
+ int32_t srid;
+ uint8_t type; /* MULTILINETYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWMLINE;
@@ -501,13 +509,14 @@
/* MULTIPOLYGONTYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWPOLY **geoms;
+ GBOX *bbox;
+ LWPOLY **geoms;
+ int32_t srid;
+ uint8_t type; /* MULTIPOLYGONTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWMPOLY;
@@ -514,13 +523,14 @@
/* COLLECTIONTYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWGEOM **geoms;
+ GBOX *bbox;
+ LWGEOM **geoms;
+ int32_t srid;
+ uint8_t type; /* COLLECTIONTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWCOLLECTION;
@@ -527,13 +537,14 @@
/* COMPOUNDTYPE */
typedef struct
{
- uint8_t type; /* COMPOUNDTYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWGEOM **geoms;
+ GBOX *bbox;
+ LWGEOM **geoms;
+ int32_t srid;
+ uint8_t type; /* COLLECTIONTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWCOMPOUND; /* "light-weight compound line" */
@@ -540,13 +551,14 @@
/* CURVEPOLYTYPE */
typedef struct
{
- uint8_t type; /* CURVEPOLYTYPE */
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
+ GBOX *bbox;
+ LWGEOM **rings;
+ int32_t srid;
+ uint8_t type; /* CURVEPOLYTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
uint32_t nrings; /* how many rings we are currently storing */
uint32_t maxrings; /* how many rings we have space for in **rings */
- LWGEOM **rings; /* list of rings (list of points) */
}
LWCURVEPOLY; /* "light-weight polygon" */
@@ -553,13 +565,14 @@
/* MULTICURVE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWGEOM **geoms;
+ GBOX *bbox;
+ LWGEOM **geoms;
+ int32_t srid;
+ uint8_t type; /* MULTICURVE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWMCURVE;
@@ -566,13 +579,14 @@
/* MULTISURFACETYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWGEOM **geoms;
+ GBOX *bbox;
+ LWGEOM **geoms;
+ int32_t srid;
+ uint8_t type; /* MULTISURFACETYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWMSURFACE;
@@ -579,13 +593,14 @@
/* POLYHEDRALSURFACETYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWPOLY **geoms;
+ GBOX *bbox;
+ LWPOLY **geoms;
+ int32_t srid;
+ uint8_t type; /* POLYHEDRALSURFACETYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWPSURFACE;
@@ -592,13 +607,14 @@
/* TINTYPE */
typedef struct
{
- uint8_t type;
- uint8_t flags;
- GBOX *bbox;
- int32_t srid;
- uint32_t ngeoms; /* how many geometries we are currently storing */
- uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
- LWTRIANGLE **geoms;
+ GBOX *bbox;
+ LWTRIANGLE **geoms;
+ int32_t srid;
+ uint8_t type; /* TINTYPE */
+ uint8_t flags;
+ char pad[2]; /* Padding to 24 bytes (unused) */
+ uint32_t ngeoms; /* how many geometries we are currently storing */
+ uint32_t maxgeoms; /* how many geometries we have space for in **geoms */
}
LWTIN;
More information about the postgis-tickets
mailing list