mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-03 00:45:41 +02:00
Make the remaining shared node lookups faster
Encode the shared nodes as quadkeys, as the comment on struct node already said they were, with a branch-free bit interleave, so that vertices that are near each other are near each other in the sorted list too. Search the list with an inlined std::lower_bound instead of bsearch. Size the Bloom filter by the number of nodes, at about 16 bits each and at most 32MB, instead of always using 34MB, so that it can usually stay in the cache, and set three bits for each node, chosen by a mixing hash, within a single 64-bit word, so that each check still touches only one cache line but has far fewer false positives than a single bit. In the pass that marks the vertices with whether they are shared nodes, this is about 1.7x faster with 70 thousand nodes and 1.9x faster with 3 million. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P2nBqZisxNQfmEmon3vE9v
This commit is contained in:
@@ -129,6 +129,23 @@ TEST_CASE("Bit reversal", "bit reversal") {
|
||||
REQUIRE(bit_reverse(0xF3D912481E6A2C48) == 0x1234567812489BCF);
|
||||
}
|
||||
|
||||
TEST_CASE("Vertex encoding matches quadkey encoding", "[projection]") {
|
||||
unsigned int values[] = {0, 1, 2, 0x7FFFFFFF, 0x80000000, 0xFFFFFFFF, 0x12345678, 0xDEADBEEF};
|
||||
for (unsigned int x : values) {
|
||||
for (unsigned int y : values) {
|
||||
REQUIRE(encode_vertex(x, y) == encode_quadkey(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long long seed = 1;
|
||||
for (size_t i = 0; i < 10000; i++) {
|
||||
seed = seed * 6364136223846793005ULL + 1442695040888963407ULL;
|
||||
unsigned int x = seed >> 32;
|
||||
unsigned int y = seed;
|
||||
REQUIRE(encode_vertex(x, y) == encode_quadkey(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("line_is_too_small") {
|
||||
drawvec dv;
|
||||
dv.emplace_back(VT_MOVETO, 4243099709, 2683872952);
|
||||
|
||||
Reference in New Issue
Block a user