From 11364b2e01161c7ae2cf0ab069249fcea93c11dc Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 19 Mar 2022 15:43:16 +0100 Subject: [PATCH] Do not reuse Osmium buffer This cleans up a bit of confusing code. We were reusing the m_buffer member in two places where a local Buffer object is fine. The idea was to save a memory allocation here for the local Buffer, but is probably not worth it and muddies up what the m_buffer is actually used for. --- src/output-flex.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/output-flex.cpp b/src/output-flex.cpp index 5086b86d3..17771f0ff 100644 --- a/src/output-flex.cpp +++ b/src/output-flex.cpp @@ -1302,20 +1302,19 @@ void output_flex_t::pending_way(osmid_t id) return; } - m_buffer.clear(); - if (!middle().way_get(id, &m_buffer)) { + osmium::memory::Buffer buffer{0, osmium::memory::Buffer::auto_grow::yes}; + if (!middle().way_get(id, &buffer)) { return; } way_delete(id); - auto &way = m_buffer.get(0); + auto &way = buffer.get(0); m_context_way = &way; get_mutex_and_call_lua_function(m_process_way, way); m_context_way = nullptr; m_num_way_nodes = std::numeric_limits::max(); - m_buffer.clear(); } void output_flex_t::select_relation_members(osmium::Relation const &relation) @@ -1786,13 +1785,14 @@ void output_flex_t::reprocess_marked() log_info( "There are {} ways to reprocess..."_format(m_stage2_way_ids->size())); + osmium::memory::Buffer buffer{0, osmium::memory::Buffer::auto_grow::yes}; for (osmid_t const id : *m_stage2_way_ids) { - m_buffer.clear(); - if (!middle().way_get(id, &m_buffer)) { + if (!middle().way_get(id, &buffer)) { continue; } - auto &way = m_buffer.get(0); + auto &way = buffer.get(0); way_modify(&way); + buffer.clear(); } // We don't need these any more so can free the memory.