[OpenLayers-Commits] r10998 - trunk/openlayers/lib/OpenLayers
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Tue Jan 4 02:43:54 EST 2011
Author: erilem
Date: 2011-01-03 23:43:54 -0800 (Mon, 03 Jan 2011)
New Revision: 10998
Modified:
trunk/openlayers/lib/OpenLayers/Util.js
Log:
small optimization for the toFloat func, r=pgiraud (closes #2875)
Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js 2011-01-03 18:18:43 UTC (rev 10997)
+++ trunk/openlayers/lib/OpenLayers/Util.js 2011-01-04 07:43:54 UTC (rev 10998)
@@ -873,13 +873,11 @@
if (precision == null) {
precision = OpenLayers.Util.DEFAULT_PRECISION;
}
- var number;
- if (precision == 0) {
+ if (typeof number !== "number") {
number = parseFloat(number);
- } else {
- number = parseFloat(parseFloat(number).toPrecision(precision));
}
- return number;
+ return precision === 0 ? number :
+ parseFloat(number.toPrecision(precision));
};
/**
More information about the Commits
mailing list