[geos-commits] r2831 - trunk/source/io

svn_geos at osgeo.org svn_geos at osgeo.org
Tue Dec 15 09:38:39 EST 2009


Author: mloskot
Date: 2009-12-15 09:38:37 -0500 (Tue, 15 Dec 2009)
New Revision: 2831

Modified:
   trunk/source/io/WKTWriter.cpp
Log:
In WKTWriter, initialise formatting buffer and avoid unnecessary calls to string constructor.

Modified: trunk/source/io/WKTWriter.cpp
===================================================================
--- trunk/source/io/WKTWriter.cpp	2009-12-14 19:21:40 UTC (rev 2830)
+++ trunk/source/io/WKTWriter.cpp	2009-12-15 14:38:37 UTC (rev 2831)
@@ -120,8 +120,8 @@
 	// the default number of decimal places is 16, which is sufficient
 	// to accomodate the maximum precision of a double.
 	int decimalPlaces = precisionModel->getMaximumSignificantDigits();
-	string fmt="%.";
-	char buffer[255];
+    std::string fmt("%.");
+    char buffer[255] = { 0 };
 	sprintf(buffer,"%i",decimalPlaces);
 	fmt.append(buffer);
 	fmt.append("f");
@@ -281,10 +281,9 @@
 }
 
 string WKTWriter::writeNumber(double d) {
-	string out="";
-	char buffer[255];
+    char buffer[255] = { 0 };
 	sprintf(buffer,formatter.c_str(),d);
-	out.append(buffer);
+	std::string out(buffer);
 	out.append("");
 	return out;
 }



More information about the geos-commits mailing list