Skip to content

Commit 247c90e

Browse files
committed
no inline.
1 parent 87382c3 commit 247c90e

File tree

2 files changed

+79
-79
lines changed

2 files changed

+79
-79
lines changed

include/geohex3.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,9 @@ typedef enum _geohex_verify_result_enum {
5454

5555
typedef size_t geohex_level_t;
5656

57-
inline geohex_coordinate_t geohex_coordinate (const long x, const long y) {
58-
const geohex_coordinate_t coordinate = { .x = x, .y = y };
59-
return coordinate;
60-
}
61-
62-
inline geohex_location_t geohex_location (const double lat, const double lng) {
63-
const geohex_location_t location = { .lat = lat, .lng = lng };
64-
return location;
65-
}
66-
67-
inline geohex_level_t geohex_calc_level_by_code(const char *code) {
68-
return strlen(code) - 2;
69-
}
70-
57+
extern geohex_coordinate_t geohex_coordinate (const long x, const long y);
58+
extern geohex_location_t geohex_location (const double lat, const double lng);
59+
extern geohex_level_t geohex_calc_level_by_code(const char *code);
7160
extern geohex_verify_result_t geohex_verify_code(const char *code);
7261
extern geohex_coordinate_t geohex_location2coordinate(const geohex_location_t location);
7362
extern geohex_location_t geohex_coordinate2location(const geohex_coordinate_t coordinate);

lib/geohex3.c

Lines changed: 76 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,76 +32,33 @@ inline geohex_coordinate_ld_t _geohex_adjust_long_double_coordinate(const geohex
3232
return _geohex_coordinate_ld((long double)coordinate.x, (long double)coordinate.y);
3333
}
3434

35-
// for performance :)
36-
static const long double GEOHEX3_CALCED_HEX_SIZE[] = {
37-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 3), // 0
38-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 4), // 1
39-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 5), // 2
40-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 6), // 3
41-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 7), // 4
42-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 8), // 5
43-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 9), // 6
44-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 10), // 7
45-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 11), // 8
46-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 12), // 9
47-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 13), // 10
48-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 14), // 11
49-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 15), // 12
50-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 16), // 13
51-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 17), // 14
52-
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 18) // 15
53-
};
54-
55-
// for performance :)
56-
static const long GEOHEX3_CALCED_POW3[] = {
57-
GEOHEX3_MACRO_POW(3L, 0),
58-
GEOHEX3_MACRO_POW(3L, 1),
59-
GEOHEX3_MACRO_POW(3L, 2),
60-
GEOHEX3_MACRO_POW(3L, 3),
61-
GEOHEX3_MACRO_POW(3L, 4),
62-
GEOHEX3_MACRO_POW(3L, 5),
63-
GEOHEX3_MACRO_POW(3L, 6),
64-
GEOHEX3_MACRO_POW(3L, 7),
65-
GEOHEX3_MACRO_POW(3L, 8),
66-
GEOHEX3_MACRO_POW(3L, 9),
67-
GEOHEX3_MACRO_POW(3L, 10),
68-
GEOHEX3_MACRO_POW(3L, 11),
69-
GEOHEX3_MACRO_POW(3L, 12),
70-
GEOHEX3_MACRO_POW(3L, 13),
71-
GEOHEX3_MACRO_POW(3L, 14),
72-
GEOHEX3_MACRO_POW(3L, 15),
73-
GEOHEX3_MACRO_POW(3L, 16),
74-
GEOHEX3_MACRO_POW(3L, 17),
75-
GEOHEX3_MACRO_POW(3L, 18)
76-
};
77-
78-
// for performance :)
79-
static const long GEOHEX3_CALCED_POW10[] = {
80-
GEOHEX3_MACRO_POW(10L, 0),
81-
GEOHEX3_MACRO_POW(10L, 1),
82-
GEOHEX3_MACRO_POW(10L, 2),
83-
GEOHEX3_MACRO_POW(10L, 3),
84-
GEOHEX3_MACRO_POW(10L, 4),
85-
GEOHEX3_MACRO_POW(10L, 5),
86-
GEOHEX3_MACRO_POW(10L, 6),
87-
GEOHEX3_MACRO_POW(10L, 7),
88-
GEOHEX3_MACRO_POW(10L, 8),
89-
GEOHEX3_MACRO_POW(10L, 9),
90-
GEOHEX3_MACRO_POW(10L, 10),
91-
GEOHEX3_MACRO_POW(10L, 11),
92-
GEOHEX3_MACRO_POW(10L, 12),
93-
GEOHEX3_MACRO_POW(10L, 13),
94-
GEOHEX3_MACRO_POW(10L, 14),
95-
GEOHEX3_MACRO_POW(10L, 15),
96-
GEOHEX3_MACRO_POW(10L, 16),
97-
GEOHEX3_MACRO_POW(10L, 17)
98-
};
99-
10035
inline long geohex_pow3(int y) {
10136
if (y > GEOHEX3_MAX_LEVEL+3) {
10237
return (long)pow(3, y);
10338
}
10439
else {
40+
// for performance :)
41+
static const long GEOHEX3_CALCED_POW3[] = {
42+
GEOHEX3_MACRO_POW(3L, 0),
43+
GEOHEX3_MACRO_POW(3L, 1),
44+
GEOHEX3_MACRO_POW(3L, 2),
45+
GEOHEX3_MACRO_POW(3L, 3),
46+
GEOHEX3_MACRO_POW(3L, 4),
47+
GEOHEX3_MACRO_POW(3L, 5),
48+
GEOHEX3_MACRO_POW(3L, 6),
49+
GEOHEX3_MACRO_POW(3L, 7),
50+
GEOHEX3_MACRO_POW(3L, 8),
51+
GEOHEX3_MACRO_POW(3L, 9),
52+
GEOHEX3_MACRO_POW(3L, 10),
53+
GEOHEX3_MACRO_POW(3L, 11),
54+
GEOHEX3_MACRO_POW(3L, 12),
55+
GEOHEX3_MACRO_POW(3L, 13),
56+
GEOHEX3_MACRO_POW(3L, 14),
57+
GEOHEX3_MACRO_POW(3L, 15),
58+
GEOHEX3_MACRO_POW(3L, 16),
59+
GEOHEX3_MACRO_POW(3L, 17),
60+
GEOHEX3_MACRO_POW(3L, 18)
61+
};
10562
return GEOHEX3_CALCED_POW3[y];
10663
}
10764
}
@@ -111,6 +68,27 @@ inline long geohex_pow10(int y) {
11168
return (long)pow(10, y);
11269
}
11370
else {
71+
// for performance :)
72+
static const long GEOHEX3_CALCED_POW10[] = {
73+
GEOHEX3_MACRO_POW(10L, 0),
74+
GEOHEX3_MACRO_POW(10L, 1),
75+
GEOHEX3_MACRO_POW(10L, 2),
76+
GEOHEX3_MACRO_POW(10L, 3),
77+
GEOHEX3_MACRO_POW(10L, 4),
78+
GEOHEX3_MACRO_POW(10L, 5),
79+
GEOHEX3_MACRO_POW(10L, 6),
80+
GEOHEX3_MACRO_POW(10L, 7),
81+
GEOHEX3_MACRO_POW(10L, 8),
82+
GEOHEX3_MACRO_POW(10L, 9),
83+
GEOHEX3_MACRO_POW(10L, 10),
84+
GEOHEX3_MACRO_POW(10L, 11),
85+
GEOHEX3_MACRO_POW(10L, 12),
86+
GEOHEX3_MACRO_POW(10L, 13),
87+
GEOHEX3_MACRO_POW(10L, 14),
88+
GEOHEX3_MACRO_POW(10L, 15),
89+
GEOHEX3_MACRO_POW(10L, 16),
90+
GEOHEX3_MACRO_POW(10L, 17)
91+
};
11492
return GEOHEX3_CALCED_POW10[y];
11593
}
11694
}
@@ -120,6 +98,25 @@ inline long double geohex_hexsize(const geohex_level_t level) {
12098
return GEOHEX3_HASH_BASE / (long double)geohex_pow3(level + 3);
12199
}
122100
else {
101+
// for performance :)
102+
static const long double GEOHEX3_CALCED_HEX_SIZE[] = {
103+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 3), // 0
104+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 4), // 1
105+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 5), // 2
106+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 6), // 3
107+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 7), // 4
108+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 8), // 5
109+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 9), // 6
110+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 10), // 7
111+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 11), // 8
112+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 12), // 9
113+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 13), // 10
114+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 14), // 11
115+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 15), // 12
116+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 16), // 13
117+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 17), // 14
118+
GEOHEX3_HASH_BASE / GEOHEX3_MACRO_POW(3.0L, 18) // 15
119+
};
123120
return GEOHEX3_CALCED_HEX_SIZE[level];
124121
}
125122
}
@@ -130,6 +127,20 @@ static long double _deg() {
130127
return deg;
131128
}
132129

130+
geohex_coordinate_t geohex_coordinate (const long x, const long y) {
131+
const geohex_coordinate_t coordinate = { .x = x, .y = y };
132+
return coordinate;
133+
}
134+
135+
geohex_location_t geohex_location (const double lat, const double lng) {
136+
const geohex_location_t location = { .lat = lat, .lng = lng };
137+
return location;
138+
}
139+
140+
geohex_level_t geohex_calc_level_by_code(const char *code) {
141+
return strlen(code) - 2;
142+
}
143+
133144
geohex_coordinate_ld_t _geohex_location2coordinate(const geohex_location_t location) {
134145
geohex_coordinate_ld_t coordinate;
135146
coordinate.x = location.lng * GEOHEX3_HASH_BASE / 180.0L;

0 commit comments

Comments
 (0)