Skip to content

Commit

Permalink
persistent cache: move try-catch further out
Browse files Browse the repository at this point in the history
Catch not-found exceptions further out when looping over nodes.
Allows the compiler to optimize the code better.
  • Loading branch information
lonvia committed Jan 7, 2017
1 parent 8bbef6a commit a940c98
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions node-persistent-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ size_t node_persistent_cache::get_list(nodelist_t &out,
out.reserve(nds.size());

for (auto const &n : nds) {
/* Check cache first */
auto loc = m_ram_cache->get(n.ref());
if (!loc.valid()) {
loc = get(n.ref());
}
if (loc.valid()) {
auto coord = proj->reproject(loc);
out.emplace_back(coord.x, coord.y);
try {
/* Check cache first */
auto loc = m_ram_cache->get(n.ref());
if (!loc.valid() && n.ref() >= 0) {
loc = m_index->get(
static_cast<osmium::unsigned_object_id_type>(n.ref()));
}
if (loc.valid()) {
auto coord = proj->reproject(loc);
out.emplace_back(coord.x, coord.y);
}
} catch (osmium::not_found const &) {
}
}

Expand Down

0 comments on commit a940c98

Please sign in to comment.