mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
I forgot how bad sorted data is in binary trees.
Swizzle the bits so deduplicating features isn't so terrible.
This commit is contained in:
parent
ea7216641b
commit
8e84a8ffda
19
pool.c
19
pool.c
@ -67,13 +67,22 @@ struct pool_val *pool(struct pool *p, char *s, int type) {
|
||||
return pool1(p, s, type, strcmp);
|
||||
}
|
||||
|
||||
static int llcmp(const char *v1, const char *v2) {
|
||||
long long *ll1 = (long long *) v1;
|
||||
long long *ll2 = (long long *) v2;
|
||||
static long long mangle(long long in) {
|
||||
int i;
|
||||
long long out = 0;
|
||||
for (i = 0; i < 64; i++) {
|
||||
out |= ((in >> i) & 1) << (63 - i);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
if (*ll1 < *ll2) {
|
||||
static int llcmp(const char *v1, const char *v2) {
|
||||
long long ll1 = mangle(*(long long *) v1);
|
||||
long long ll2 = mangle(*(long long *) v2);
|
||||
|
||||
if (ll1 < ll2) {
|
||||
return -1;
|
||||
} else if (*ll1 > *ll2) {
|
||||
} else if (ll1 > ll2) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user