Skip to content

Commit 90966d0

Browse files
minor speed improvement
1 parent 5d3df01 commit 90966d0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mapcodelib/mapcoder.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
309309
int ydirection,
310310
const encodeRec *enc) // append extra characters to result for more precision
311311
{
312+
if (extraDigits > 0) { // anything to do?
312313
char *s = result + strlen(result);
313314
int factorx = MAX_PRECISION_FACTOR * dividerx4; // 30^4
314315
int factory = MAX_PRECISION_FACTOR * dividery; // 30^4
@@ -319,7 +320,7 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
319320
if (valx<0) { valx=0; } else if (valx>=factorx) { valx=factorx-1; }
320321
if (valy<0) { valy=0; } else if (valy>=factory) { valy=factory-1; }
321322

322-
if (extraDigits < 0) { extraDigits = 0; } else if (extraDigits > MAX_PRECISION_DIGITS) {
323+
if (extraDigits > MAX_PRECISION_DIGITS) {
323324
extraDigits = MAX_PRECISION_DIGITS;
324325
}
325326

@@ -347,8 +348,9 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
347348
if (extraDigits-- > 0) {
348349
*s++ = encode_chars[row2 * 6 + column2];
349350
}
350-
*s = 0;
351351
}
352+
*s = 0; // terminate the result
353+
}
352354
}
353355

354356
#define decodeChar(c) decode_chars[(unsigned char)c] // force c to be in range of the index, between 0 and 255

0 commit comments

Comments
 (0)