mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 01:45:41 +02:00
Just use a standard C++ type for deduplicating instead of reinventing the wheel
This commit is contained in:
@@ -67,32 +67,6 @@ struct pool_val *pool(struct pool *p, char *s, int type) {
|
|||||||
return pool1(p, s, type, strcmp);
|
return pool1(p, s, type, strcmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct pool_val *pool_long_long(struct pool *p, long long *s, int type) {
|
|
||||||
return pool1(p, (char *) s, type, llcmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pool_free1(struct pool *p, void (*func)(void *)) {
|
void pool_free1(struct pool *p, void (*func)(void *)) {
|
||||||
while (p->head != NULL) {
|
while (p->head != NULL) {
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ struct pool {
|
|||||||
|
|
||||||
|
|
||||||
struct pool_val *pool(struct pool *p, char *s, int type);
|
struct pool_val *pool(struct pool *p, char *s, int type);
|
||||||
struct pool_val *pool_long_long(struct pool *p, long long *val, int type);
|
|
||||||
void pool_free(struct pool *p);
|
void pool_free(struct pool *p);
|
||||||
void pool_free_strings(struct pool *p);
|
void pool_free_strings(struct pool *p);
|
||||||
void pool_init(struct pool *p, int n);
|
void pool_init(struct pool *p, int n);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -347,10 +348,10 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
for (line_detail = detail; line_detail >= MIN_DETAIL; line_detail--) {
|
for (line_detail = detail; line_detail >= MIN_DETAIL; line_detail--) {
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
struct pool keys, values, dup;
|
struct pool keys, values;
|
||||||
pool_init(&keys, 0);
|
pool_init(&keys, 0);
|
||||||
pool_init(&values, 0);
|
pool_init(&values, 0);
|
||||||
pool_init(&dup, 1);
|
std::map<long long, int> dup;
|
||||||
|
|
||||||
double interval = 1;
|
double interval = 1;
|
||||||
double seq = 0;
|
double seq = 0;
|
||||||
@@ -370,11 +371,10 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pool_val *pv = pool_long_long(&dup, &i->fpos, 0);
|
if (dup.count(i->fpos) != 0) {
|
||||||
if (pv->n == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pv->n = 0;
|
dup.insert(std::pair<long long, int>(i->fpos, 1));
|
||||||
|
|
||||||
int t;
|
int t;
|
||||||
char *meta = metabase + i->fpos;
|
char *meta = metabase + i->fpos;
|
||||||
@@ -484,7 +484,6 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
|
|
||||||
pool_free(&keys);
|
pool_free(&keys);
|
||||||
pool_free(&values);
|
pool_free(&values);
|
||||||
pool_free(&dup);
|
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
std::string compressed;
|
std::string compressed;
|
||||||
|
|||||||
Reference in New Issue
Block a user