From edf6f1e0e63e4af3a7695bed8f35936b477476e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 23:50:54 +0000 Subject: [PATCH] tag_store: reject other elements' tag entries with a bit filter collect_tags_framed reads every local tag entry of a cell and keeps those of the elements being printed, binary-searching each entry's id among them. Most entries of a cell belong to other elements. It now builds an Id_Bit_Filter of the cell's ids and skips entries whose id the filter rejects before the bound checks and the binary search. On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM, median CPU of 3 alternating runs: (rel['seamark:type']; >; way['seamark:type']; >; node['seamark:type']; ); out meta; 4.66 s -> 3.66 s Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35 --- src/overpass_api/data/tag_store.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/overpass_api/data/tag_store.h b/src/overpass_api/data/tag_store.h index d1f565233..19ef49800 100644 --- a/src/overpass_api/data/tag_store.h +++ b/src/overpass_api/data/tag_store.h @@ -20,6 +20,7 @@ #define DE__OSM3S___OVERPASS_API__DATA__TAG_STORE_H +#include "abstract_processing.h" #include "filenames.h" #include "../core/datatypes.h" #include "../../template_db/block_backend.h" @@ -249,16 +250,19 @@ void collect_tags_framed uint32 coarse_index, Id_Type lower_id_bound, Id_Type upper_id_bound) { + const std::vector< Id_Type >& ids = ids_by_coarse[coarse_index]; + // Most of a cell's tag entries belong to other elements: reject those with one bit test. + Id_Bit_Filter id_filter(ids); while ((!(tag_it == items_db.range_end())) && (((tag_it.index().index) & 0x7fffff00) < coarse_index)) ++tag_it; while ((!(tag_it == items_db.range_end())) && (((tag_it.index().index) & 0x7fffff00) == coarse_index)) { - if (!(tag_it.object() < lower_id_bound) && + if (id_filter.maybe_contains(tag_it.object().val()) && + !(tag_it.object() < lower_id_bound) && (tag_it.object() < upper_id_bound) && - (binary_search(ids_by_coarse[coarse_index].begin(), - ids_by_coarse[coarse_index].end(), tag_it.object()))) + (binary_search(ids.begin(), ids.end(), tag_it.object()))) tags_by_id[tag_it.object()].push_back (std::make_pair(tag_it.index().key, tag_it.index().value)); ++tag_it;