Skip to content

Commit

Permalink
Merge pull request googollee#27 from Arthur2e5/patch-3
Browse files Browse the repository at this point in the history
Make internal functions static
  • Loading branch information
googollee committed May 9, 2016
2 parents 8fdab53 + 226cdc6 commit 95f69a5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions c/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@

#include "transform.h"

int outOfChina(double lat, double lng) {
#undef INLINE
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900L
#define INLINE inline
#else
#define INLINE
#endif /* STDC */

#define fabs(x) __ev_fabs(x)
/* do not use >=, or compiler may not know to optimize this with a simple (x & 0x80...0). */
INLINE static double __ev_fabs(x){ return x > 0.0 ? x : -x; }

INLINE static int outOfChina(double lat, double lng) {
if (lng < 72.004 || lng > 137.8347) {
return 1;
}
Expand Down Expand Up @@ -31,7 +42,7 @@ void transform(double x, double y, double *lat, double *lng) {
*lng += (150.0*sin(x/12.0*M_PI) + 300.0*sin(x/30.0*M_PI)) * 2.0 / 3.0;
}

void delta(double lat, double lng, double *dLat, double *dLng) {
static void delta(double lat, double lng, double *dLat, double *dLng) {
if ((dLat == NULL) || (dLng == NULL)) {
return;
}
Expand Down Expand Up @@ -97,7 +108,7 @@ void gcj2wgs_exact(double gcjLat, double gcjLng, double *wgsLat, double *wgsLng)
}

// 1 - cos(x) == 2 sin^2(x/2)
double oneMinusCos(double x)
INLINE static double oneMinusCos(double x)
{
double s = sin(x/2);
return s*s*2;
Expand Down

0 comments on commit 95f69a5

Please sign in to comment.