[mapcode] 01/04: minor speed improvement
Stefan Fritsch
sf at moszumanska.debian.org
Wed Nov 2 23:28:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
sf pushed a commit to tag v2.1.2
in repository mapcode.
commit 90966d018c2a9de8f832adb8543d2c777f4fdaf4
Author: Mapcode C Developer <pieter.geelen at mapcode.com>
Date: Mon Aug 24 22:13:07 2015 +0200
minor speed improvement
---
mapcodelib/mapcoder.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mapcodelib/mapcoder.c b/mapcodelib/mapcoder.c
index 54d8799..eb49459 100644
--- a/mapcodelib/mapcoder.c
+++ b/mapcodelib/mapcoder.c
@@ -309,6 +309,7 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
int ydirection,
const encodeRec *enc) // append extra characters to result for more precision
{
+ if (extraDigits > 0) { // anything to do?
char *s = result + strlen(result);
int factorx = MAX_PRECISION_FACTOR * dividerx4; // 30^4
int factory = MAX_PRECISION_FACTOR * dividery; // 30^4
@@ -319,7 +320,7 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
if (valx<0) { valx=0; } else if (valx>=factorx) { valx=factorx-1; }
if (valy<0) { valy=0; } else if (valy>=factory) { valy=factory-1; }
- if (extraDigits < 0) { extraDigits = 0; } else if (extraDigits > MAX_PRECISION_DIGITS) {
+ if (extraDigits > MAX_PRECISION_DIGITS) {
extraDigits = MAX_PRECISION_DIGITS;
}
@@ -347,8 +348,9 @@ static void encodeExtension(char *result, int extrax4, int extray, int dividerx4
if (extraDigits-- > 0) {
*s++ = encode_chars[row2 * 6 + column2];
}
- *s = 0;
}
+ *s = 0; // terminate the result
+ }
}
#define decodeChar(c) decode_chars[(unsigned char)c] // force c to be in range of the index, between 0 and 255
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapcode.git
More information about the Pkg-grass-devel
mailing list