[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-32-g2f7b95e

git at osgeo.org git at osgeo.org
Wed Mar 4 15:21:23 PST 2020


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  2f7b95e6b7e783c1ed9260c217c0d237ea3bd9a6 (commit)
       via  5304a6f69714caa1822e51a7c3e3e4967174b690 (commit)
      from  af7bb360b5d9cc02dbf04f6dd395e0706536b5a4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2f7b95e6b7e783c1ed9260c217c0d237ea3bd9a6
Merge: af7bb36 5304a6f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Mar 4 15:20:47 2020 -0800

    Merge branch 'master-4614'


commit 5304a6f69714caa1822e51a7c3e3e4967174b690
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Mar 4 11:15:24 2020 -0800

    Optimize stringbuffer_append to avoid strlen calls, References #4614

diff --git a/liblwgeom/lwout_kml.c b/liblwgeom/lwout_kml.c
index 231c8b4..eb3ebe3 100644
--- a/liblwgeom/lwout_kml.c
+++ b/liblwgeom/lwout_kml.c
@@ -107,10 +107,10 @@ ptarray_to_kml2_sb(const POINTARRAY *pa, int precision, stringbuffer_t *sb)
 	{
 		getPoint4d_p(pa, i, &pt);
 		d = (double*)(&pt);
-		if ( i ) stringbuffer_append(sb," ");
+		if ( i ) stringbuffer_append_len(sb," ",1);
 		for (j = 0; j < dims; j++)
 		{
-			if ( j ) stringbuffer_append(sb,",");
+			if ( j ) stringbuffer_append_len(sb,",",1);
 			if( fabs(d[j]) < OUT_MAX_DOUBLE )
 			{
 				if ( stringbuffer_aprintf(sb, "%.*f", precision, d[j]) < 0 ) return LW_FAILURE;
diff --git a/liblwgeom/lwout_wkt.c b/liblwgeom/lwout_wkt.c
index ab05f6b..60b4bbd 100644
--- a/liblwgeom/lwout_wkt.c
+++ b/liblwgeom/lwout_wkt.c
@@ -46,19 +46,19 @@ static void dimension_qualifiers_to_wkt_sb(const LWGEOM *geom, stringbuffer_t *s
 	if ( (variant & WKT_EXTENDED) && FLAGS_GET_M(geom->flags) && (!FLAGS_GET_Z(geom->flags)) )
 #endif
 	{
-		stringbuffer_append(sb, "M"); /* "M" */
+		stringbuffer_append_len(sb, "M", 1); /* "M" */
 		return;
 	}
 
 	/* ISO WKT: POINT ZM (0 0 0 0) */
 	if ( (variant & WKT_ISO) && (FLAGS_NDIMS(geom->flags) > 2) )
 	{
-		stringbuffer_append(sb, " ");
+		stringbuffer_append_len(sb, " ", 1);
 		if ( FLAGS_GET_Z(geom->flags) )
-			stringbuffer_append(sb, "Z");
+			stringbuffer_append_len(sb, "Z", 1);
 		if ( FLAGS_GET_M(geom->flags) )
-			stringbuffer_append(sb, "M");
-		stringbuffer_append(sb, " ");
+			stringbuffer_append_len(sb, "M", 1);
+		stringbuffer_append_len(sb, " ", 1);
 	}
 }
 
@@ -70,9 +70,9 @@ static void empty_to_wkt_sb(stringbuffer_t *sb)
 {
 	if ( ! strchr(" ,(", stringbuffer_lastchar(sb)) ) /* "EMPTY" */
 	{
-		stringbuffer_append(sb, " ");
+		stringbuffer_append_len(sb, " ", 1);
 	}
-	stringbuffer_append(sb, "EMPTY");
+	stringbuffer_append_len(sb, "EMPTY", 5);
 }
 
 /*
@@ -94,7 +94,7 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
 
 	/* Opening paren? */
 	if ( ! (variant & WKT_NO_PARENS) )
-		stringbuffer_append(sb, "(");
+		stringbuffer_append_len(sb, "(", 1);
 
 	/* Digits and commas */
 	for (i = 0; i < ptarray->npoints; i++)
@@ -103,13 +103,13 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
 
 		/* Commas before ever coord but the first */
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 
 		for (j = 0; j < dimensions; j++)
 		{
 			/* Spaces before every ordinate but the first */
 			if ( j > 0 )
-				stringbuffer_append(sb, " ");
+				stringbuffer_append_len(sb, " ", 1);
 			lwprint_double(dbl_ptr[j],
 				       precision,
 				       coord,
@@ -120,7 +120,7 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
 
 	/* Closing paren? */
 	if ( ! (variant & WKT_NO_PARENS) )
-		stringbuffer_append(sb, ")");
+		stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -137,7 +137,7 @@ static void lwpoint_to_wkt_sb(const LWPOINT *pt, stringbuffer_t *sb, int precisi
 {
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "POINT"); /* "POINT" */
+		stringbuffer_append_len(sb, "POINT", 5); /* "POINT" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)pt, sb, variant);
 	}
 
@@ -157,7 +157,7 @@ static void lwline_to_wkt_sb(const LWLINE *line, stringbuffer_t *sb, int precisi
 {
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "LINESTRING"); /* "LINESTRING" */
+		stringbuffer_append_len(sb, "LINESTRING", 10); /* "LINESTRING" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)line, sb, variant);
 	}
 	if ( lwline_is_empty(line) )
@@ -177,7 +177,7 @@ static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precisi
 	uint32_t i = 0;
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "POLYGON"); /* "POLYGON" */
+		stringbuffer_append_len(sb, "POLYGON", 7); /* "POLYGON" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)poly, sb, variant);
 	}
 	if ( lwpoly_is_empty(poly) )
@@ -186,14 +186,14 @@ static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precisi
 		return;
 	}
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	for ( i = 0; i < poly->nrings; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		ptarray_to_wkt_sb(poly->rings[i], sb, precision, variant);
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -203,7 +203,7 @@ static void lwcircstring_to_wkt_sb(const LWCIRCSTRING *circ, stringbuffer_t *sb,
 {
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "CIRCULARSTRING"); /* "CIRCULARSTRING" */
+		stringbuffer_append_len(sb, "CIRCULARSTRING", 14); /* "CIRCULARSTRING" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)circ, sb, variant);
 	}
 	if ( lwcircstring_is_empty(circ) )
@@ -224,7 +224,7 @@ static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int p
 	uint32_t i = 0;
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "MULTIPOINT"); /* "MULTIPOINT" */
+		stringbuffer_append_len(sb, "MULTIPOINT", 10); /* "MULTIPOINT" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)mpoint, sb, variant);
 	}
 	if ( mpoint->ngeoms < 1 )
@@ -232,16 +232,16 @@ static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int p
 		empty_to_wkt_sb(sb);
 		return;
 	}
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < mpoint->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* We don't want type strings or parens on our subgeoms */
 		lwpoint_to_wkt_sb(mpoint->geoms[i], sb, precision, variant | WKT_NO_PARENS | WKT_NO_TYPE );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -253,7 +253,7 @@ static void lwmline_to_wkt_sb(const LWMLINE *mline, stringbuffer_t *sb, int prec
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "MULTILINESTRING"); /* "MULTILINESTRING" */
+		stringbuffer_append_len(sb, "MULTILINESTRING", 15); /* "MULTILINESTRING" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)mline, sb, variant);
 	}
 	if ( mline->ngeoms < 1 )
@@ -262,16 +262,16 @@ static void lwmline_to_wkt_sb(const LWMLINE *mline, stringbuffer_t *sb, int prec
 		return;
 	}
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < mline->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* We don't want type strings on our subgeoms */
 		lwline_to_wkt_sb(mline->geoms[i], sb, precision, variant | WKT_NO_TYPE );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -283,7 +283,7 @@ static void lwmpoly_to_wkt_sb(const LWMPOLY *mpoly, stringbuffer_t *sb, int prec
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "MULTIPOLYGON"); /* "MULTIPOLYGON" */
+		stringbuffer_append_len(sb, "MULTIPOLYGON", 12); /* "MULTIPOLYGON" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)mpoly, sb, variant);
 	}
 	if ( mpoly->ngeoms < 1 )
@@ -292,16 +292,16 @@ static void lwmpoly_to_wkt_sb(const LWMPOLY *mpoly, stringbuffer_t *sb, int prec
 		return;
 	}
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < mpoly->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* We don't want type strings on our subgeoms */
 		lwpoly_to_wkt_sb(mpoly->geoms[i], sb, precision, variant | WKT_NO_TYPE );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -315,7 +315,7 @@ static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "COMPOUNDCURVE"); /* "COMPOUNDCURVE" */
+		stringbuffer_append_len(sb, "COMPOUNDCURVE", 13); /* "COMPOUNDCURVE" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)comp, sb, variant);
 	}
 	if ( comp->ngeoms < 1 )
@@ -324,13 +324,13 @@ static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int
 		return;
 	}
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < comp->ngeoms; i++ )
 	{
 		int type = comp->geoms[i]->type;
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* Linestring subgeoms don't get type identifiers */
 		if ( type == LINETYPE )
 		{
@@ -346,7 +346,7 @@ static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int
 			lwerror("lwcompound_to_wkt_sb: Unknown type received %d - %s", type, lwtype_name(type));
 		}
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -360,7 +360,7 @@ static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb,
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "CURVEPOLYGON"); /* "CURVEPOLYGON" */
+		stringbuffer_append_len(sb, "CURVEPOLYGON", 12); /* "CURVEPOLYGON" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)cpoly, sb, variant);
 	}
 	if ( cpoly->nrings < 1 )
@@ -368,13 +368,13 @@ static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb,
 		empty_to_wkt_sb(sb);
 		return;
 	}
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < cpoly->nrings; i++ )
 	{
 		int type = cpoly->rings[i]->type;
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		switch (type)
 		{
 		case LINETYPE:
@@ -393,7 +393,7 @@ static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb,
 			lwerror("lwcurvepoly_to_wkt_sb: Unknown type received %d - %s", type, lwtype_name(type));
 		}
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 
@@ -408,7 +408,7 @@ static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int pr
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "MULTICURVE"); /* "MULTICURVE" */
+		stringbuffer_append_len(sb, "MULTICURVE", 10); /* "MULTICURVE" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)mcurv, sb, variant);
 	}
 	if ( mcurv->ngeoms < 1 )
@@ -416,13 +416,13 @@ static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int pr
 		empty_to_wkt_sb(sb);
 		return;
 	}
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < mcurv->ngeoms; i++ )
 	{
 		int type = mcurv->geoms[i]->type;
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		switch (type)
 		{
 		case LINETYPE:
@@ -441,7 +441,7 @@ static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int pr
 			lwerror("lwmcurve_to_wkt_sb: Unknown type received %d - %s", type, lwtype_name(type));
 		}
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 
@@ -456,7 +456,7 @@ static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, in
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "MULTISURFACE"); /* "MULTISURFACE" */
+		stringbuffer_append_len(sb, "MULTISURFACE", 12); /* "MULTISURFACE" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)msurf, sb, variant);
 	}
 	if ( msurf->ngeoms < 1 )
@@ -464,13 +464,13 @@ static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, in
 		empty_to_wkt_sb(sb);
 		return;
 	}
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 	for ( i = 0; i < msurf->ngeoms; i++ )
 	{
 		int type = msurf->geoms[i]->type;
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		switch (type)
 		{
 		case POLYGONTYPE:
@@ -485,7 +485,7 @@ static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, in
 			lwerror("lwmsurface_to_wkt_sb: Unknown type received %d - %s", type, lwtype_name(type));
 		}
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -499,7 +499,7 @@ static void lwcollection_to_wkt_sb(const LWCOLLECTION *collection, stringbuffer_
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "GEOMETRYCOLLECTION"); /* "GEOMETRYCOLLECTION" */
+		stringbuffer_append_len(sb, "GEOMETRYCOLLECTION", 18); /* "GEOMETRYCOLLECTION" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)collection, sb, variant);
 	}
 	if ( collection->ngeoms < 1 )
@@ -507,15 +507,15 @@ static void lwcollection_to_wkt_sb(const LWCOLLECTION *collection, stringbuffer_
 		empty_to_wkt_sb(sb);
 		return;
 	}
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are children */
 	for ( i = 0; i < collection->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		lwgeom_to_wkt_sb((LWGEOM*)collection->geoms[i], sb, precision, variant );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -525,7 +525,7 @@ static void lwtriangle_to_wkt_sb(const LWTRIANGLE *tri, stringbuffer_t *sb, int
 {
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "TRIANGLE"); /* "TRIANGLE" */
+		stringbuffer_append_len(sb, "TRIANGLE", 8); /* "TRIANGLE" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)tri, sb, variant);
 	}
 	if ( lwtriangle_is_empty(tri) )
@@ -534,9 +534,9 @@ static void lwtriangle_to_wkt_sb(const LWTRIANGLE *tri, stringbuffer_t *sb, int
 		return;
 	}
 
-	stringbuffer_append(sb, "("); /* Triangles have extraneous brackets */
+	stringbuffer_append_len(sb, "(", 1); /* Triangles have extraneous brackets */
 	ptarray_to_wkt_sb(tri->points, sb, precision, variant);
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -548,7 +548,7 @@ static void lwtin_to_wkt_sb(const LWTIN *tin, stringbuffer_t *sb, int precision,
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "TIN"); /* "TIN" */
+		stringbuffer_append_len(sb, "TIN", 3); /* "TIN" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)tin, sb, variant);
 	}
 	if ( tin->ngeoms < 1 )
@@ -557,15 +557,15 @@ static void lwtin_to_wkt_sb(const LWTIN *tin, stringbuffer_t *sb, int precision,
 		return;
 	}
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	for ( i = 0; i < tin->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* We don't want type strings on our subgeoms */
 		lwtriangle_to_wkt_sb(tin->geoms[i], sb, precision, variant | WKT_NO_TYPE );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 /*
@@ -577,7 +577,7 @@ static void lwpsurface_to_wkt_sb(const LWPSURFACE *psurf, stringbuffer_t *sb, in
 
 	if ( ! (variant & WKT_NO_TYPE) )
 	{
-		stringbuffer_append(sb, "POLYHEDRALSURFACE"); /* "POLYHEDRALSURFACE" */
+		stringbuffer_append_len(sb, "POLYHEDRALSURFACE", 17); /* "POLYHEDRALSURFACE" */
 		dimension_qualifiers_to_wkt_sb((LWGEOM*)psurf, sb, variant);
 	}
 	if ( psurf->ngeoms < 1 )
@@ -588,15 +588,15 @@ static void lwpsurface_to_wkt_sb(const LWPSURFACE *psurf, stringbuffer_t *sb, in
 
 	variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
 
-	stringbuffer_append(sb, "(");
+	stringbuffer_append_len(sb, "(", 1);
 	for ( i = 0; i < psurf->ngeoms; i++ )
 	{
 		if ( i > 0 )
-			stringbuffer_append(sb, ",");
+			stringbuffer_append_len(sb, ",", 1);
 		/* We don't want type strings on our subgeoms */
 		lwpoly_to_wkt_sb(psurf->geoms[i], sb, precision, variant | WKT_NO_TYPE );
 	}
-	stringbuffer_append(sb, ")");
+	stringbuffer_append_len(sb, ")", 1);
 }
 
 
diff --git a/liblwgeom/lwout_x3d.c b/liblwgeom/lwout_x3d.c
index bfb1bf8..f126561 100644
--- a/liblwgeom/lwout_x3d.c
+++ b/liblwgeom/lwout_x3d.c
@@ -521,7 +521,7 @@ ptarray_to_x3d3_sb(POINTARRAY *pa, int precision, int opts, int is_closed, strin
 				lwprint_double(
 				    pt.y, precision, y, OUT_DOUBLE_BUFFER_SIZE);
 
-				if ( i ) stringbuffer_append(sb," ");
+				if ( i ) stringbuffer_append_len(sb," ",1);
 
 				if ( ( opts & LW_X3D_FLIP_XY) )
 					stringbuffer_aprintf(sb, "%s %s", y, x);
@@ -547,7 +547,7 @@ ptarray_to_x3d3_sb(POINTARRAY *pa, int precision, int opts, int is_closed, strin
 				lwprint_double(
 				    pt.z, precision, z, OUT_DOUBLE_BUFFER_SIZE);
 
-				if ( i ) stringbuffer_append(sb," ");
+				if ( i ) stringbuffer_append_len(sb," ",1);
 
 				if ( ( opts & LW_X3D_FLIP_XY) )
 					stringbuffer_aprintf(sb, "%s %s %s", y, x, z);
diff --git a/liblwgeom/stringbuffer.h b/liblwgeom/stringbuffer.h
index bead7c9..1a2d519 100644
--- a/liblwgeom/stringbuffer.h
+++ b/liblwgeom/stringbuffer.h
@@ -81,16 +81,27 @@ stringbuffer_makeroom(stringbuffer_t *s, size_t size_to_add)
 		s->str_end = s->str_start + current_size;
 	}
 }
+
+
 /**
- * Append the specified string to the stringbuffer_t.
+ * Append the specified string to the stringbuffer_t using known length
  */
 inline static void
-stringbuffer_append(stringbuffer_t *s, const char *a)
+stringbuffer_append_len(stringbuffer_t *s, const char *a, size_t alen)
 {
-	int alen = strlen(a); /* Length of string to append */
 	int alen0 = alen + 1; /* Length including null terminator */
 	stringbuffer_makeroom(s, alen0);
 	memcpy(s->str_end, a, alen0);
 	s->str_end += alen;
 }
+
+/**
+ * Append the specified string to the stringbuffer_t.
+ */
+inline static void
+stringbuffer_append(stringbuffer_t *s, const char *a)
+{
+	int alen = strlen(a); /* Length of string to append */
+	stringbuffer_append_len(s, a, alen);
+}
 #endif /* _STRINGBUFFER_H */

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/lwout_kml.c    |   4 +-
 liblwgeom/lwout_wkt.c    | 122 +++++++++++++++++++++++------------------------
 liblwgeom/lwout_x3d.c    |   4 +-
 liblwgeom/stringbuffer.h |  17 +++++--
 4 files changed, 79 insertions(+), 68 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list