Merge pull request #1094 from gberaudo/fixes

Several fixes: remove dead code, fix Int->String conversion for INT_MIN, remove duplicated coordinate from encoded polyline.
This commit is contained in:
Dennis Luxen
2014-06-26 11:54:45 +02:00
8 changed files with 46 additions and 33 deletions
+6 -5
View File
@@ -40,18 +40,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// precision: position after decimal point
// length: maximum number of digits including comma and decimals
// work with negative values to prevent overflowing when taking -value
template <int length, int precision> static inline char *printInt(char *buffer, int value)
{
bool minus = false;
if (value < 0)
bool minus = true;
if (value > 0)
{
minus = true;
minus = false;
value = -value;
}
buffer += length - 1;
for (int i = 0; i < precision; i++)
{
*buffer = '0' + (value % 10);
*buffer = '0' - (value % 10);
value /= 10;
buffer--;
}
@@ -59,7 +60,7 @@ template <int length, int precision> static inline char *printInt(char *buffer,
buffer--;
for (int i = precision + 1; i < length; i++)
{
*buffer = '0' + (value % 10);
*buffer = '0' - (value % 10);
value /= 10;
if (value == 0)
break;