Skip to content

Commit efff241

Browse files
committed
Cleanup middle_ram_t code
1 parent 2f805a0 commit efff241

File tree

2 files changed

+11
-41
lines changed

2 files changed

+11
-41
lines changed

src/middle-ram.cpp

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
* emit the final geometry-enabled output formats
88
*/
99

10-
#include <stdexcept>
11-
1210
#include <cassert>
13-
#include <cstdio>
11+
#include <memory>
1412

1513
#include <osmium/builder/attr.hpp>
1614

17-
#include "id-tracker.hpp"
1815
#include "middle-ram.hpp"
1916
#include "node-ram-cache.hpp"
2017
#include "options.hpp"
@@ -64,10 +61,6 @@ size_t middle_ram_t::nodes_get_list(osmium::WayNodeList *nodes) const
6461
return count;
6562
}
6663

67-
void middle_ram_t::release_relations() { m_rels.clear(); }
68-
69-
void middle_ram_t::release_ways() { m_ways.clear(); }
70-
7164
bool middle_ram_t::way_get(osmid_t id, osmium::memory::Buffer &buffer) const
7265
{
7366
auto const *ele = m_ways.get(id);
@@ -117,46 +110,26 @@ bool middle_ram_t::relation_get(osmid_t id,
117110
return true;
118111
}
119112

120-
void middle_ram_t::analyze()
121-
{ /* No need */
122-
}
123-
124-
void middle_ram_t::start() {}
125-
126113
void middle_ram_t::stop(osmium::thread::Pool &)
127114
{
128-
m_cache.reset(nullptr);
129-
130-
release_ways();
131-
release_relations();
115+
m_cache.reset();
116+
m_ways.clear();
117+
m_rels.clear();
132118
}
133119

134-
void middle_ram_t::commit() {}
135-
136120
middle_ram_t::middle_ram_t(options_t const *options)
137121
: m_ways(), m_rels(),
138122
m_cache(new node_ram_cache{options->alloc_chunkwise, options->cache}),
139123
m_extra_attributes(options->extra_attributes)
140124
{}
141125

142-
middle_ram_t::~middle_ram_t()
143-
{
144-
//instance.reset();
145-
}
146-
147126
idlist_t middle_ram_t::relations_using_way(osmid_t) const
148127
{
149-
// this function shouldn't be called - relations_using_way is only used in
150-
// slim mode, and a middle_ram_t shouldn't be constructed if the slim mode
151-
// option is set.
152-
throw std::runtime_error{
153-
"middle_ram_t::relations_using_way is unimplemented, and "
154-
"should not have been called. This is probably a bug, please "
155-
"report it at https://github.com/openstreetmap/osm2pgsql/issues"};
128+
assert(false && "Should only be called in slim mode");
129+
return {};
156130
}
157131

158-
std::shared_ptr<middle_query_t>
159-
middle_ram_t::get_query_instance()
132+
std::shared_ptr<middle_query_t> middle_ram_t::get_query_instance()
160133
{
161134
return shared_from_this();
162135
}

src/middle-ram.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ class elem_cache_t
9292
struct middle_ram_t : public middle_t, public middle_query_t
9393
{
9494
middle_ram_t(options_t const *options);
95-
virtual ~middle_ram_t();
95+
virtual ~middle_ram_t() noexcept = default;
9696

97-
void start() override;
97+
void start() override {}
9898
void stop(osmium::thread::Pool &pool) override;
99-
void analyze(void) override;
100-
void commit(void) override;
99+
void analyze() override {}
100+
void commit() override {}
101101

102102
void node_set(osmium::Node const &node) override;
103103
size_t nodes_get_list(osmium::WayNodeList *nodes) const override;
@@ -123,9 +123,6 @@ struct middle_ram_t : public middle_t, public middle_query_t
123123
std::shared_ptr<middle_query_t> get_query_instance() override;
124124

125125
private:
126-
void release_ways();
127-
void release_relations();
128-
129126
struct ramWay
130127
{
131128
taglist_t tags;

0 commit comments

Comments
 (0)