Skip to content

Commit 3dc2233

Browse files
committed
Add lots of const's
1 parent 7b9b686 commit 3dc2233

70 files changed

Lines changed: 320 additions & 320 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

benchmarks/osmium_benchmark_static_vs_dynamic_index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int main(int argc, char* argv[]) {
4747
try {
4848
const std::string input_filename{argv[1]};
4949

50-
osmium::memory::Buffer buffer{osmium::io::read_file(input_filename)};
50+
const osmium::memory::Buffer buffer{osmium::io::read_file(input_filename)};
5151

5252
const auto& map_factory = osmium::index::MapFactory<osmium::unsigned_object_id_type, osmium::Location>::instance();
5353

benchmarks/osmium_benchmark_write_pbf.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ int main(int argc, char* argv[]) {
1818
}
1919

2020
try {
21-
std::string input_filename{argv[1]};
22-
std::string output_filename{argv[2]};
21+
const std::string input_filename{argv[1]};
22+
const std::string output_filename{argv[2]};
2323

2424
osmium::io::Reader reader{input_filename};
25-
osmium::io::File output_file{output_filename, "pbf"};
26-
osmium::io::Header header;
25+
const osmium::io::File output_file{output_filename, "pbf"};
26+
const osmium::io::Header header;
2727
osmium::io::Writer writer{output_file, header, osmium::io::overwrite::allow};
2828

2929
while (osmium::memory::Buffer buffer = reader.read()) { // NOLINT(bugprone-use-after-move) Bug in clang-tidy https://bugs.llvm.org/show_bug.cgi?id=36516

examples/osmium_area_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ int main(int argc, char* argv[]) {
122122
return 1;
123123
}
124124

125-
osmium::io::File input_file{argv[2]};
125+
const osmium::io::File input_file{argv[2]};
126126

127127
// Configuration for the multipolygon assembler. Here the default settings
128128
// are used, but you could change multiple settings.
129-
osmium::area::Assembler::config_type assembler_config;
129+
const osmium::area::Assembler::config_type assembler_config;
130130

131131
// Set up a filter matching only forests. This will be used to only build
132132
// areas with matching tags.

examples/osmium_change_tags.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ int main(int argc, char* argv[]) {
153153
}
154154

155155
// Get input and output file names from command line.
156-
std::string input_file_name{argv[1]};
157-
std::string output_file_name{argv[2]};
156+
const std::string input_file_name{argv[1]};
157+
const std::string output_file_name{argv[2]};
158158

159159
try {
160160
// Initialize Reader

examples/osmium_count.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main(int argc, char* argv[]) {
6868
try {
6969
// The Reader is initialized here with an osmium::io::File, but could
7070
// also be directly initialized with a file name.
71-
osmium::io::File input_file{argv[1]};
71+
const osmium::io::File input_file{argv[1]};
7272
osmium::io::Reader reader{input_file};
7373

7474
// Create an instance of our own CountHandler and push the data from the
@@ -88,7 +88,7 @@ int main(int argc, char* argv[]) {
8888
// (though not this one) can use huge amounts of data. So checking actual
8989
// memore usage is often useful and can be done easily with this class.
9090
// (Currently only works on Linux, not macOS and Windows.)
91-
osmium::MemoryUsage memory;
91+
const osmium::MemoryUsage memory;
9292

9393
std::cout << "\nMemory used: " << memory.peak() << " MBytes\n";
9494
} catch (const std::exception& e) {

examples/osmium_create_pois.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ int main(int argc, char* argv[]) {
4040
}
4141

4242
// Get output file name from command line.
43-
std::string output_file_name{argv[1]};
43+
const std::string output_file_name{argv[1]};
4444

4545
// If output file name is "-", this means STDOUT. Set the OPL file type
4646
// in this case. Otherwise take the file type from the file name suffix.
47-
osmium::io::File output_file{output_file_name, output_file_name == "-" ? ".opl" : ""};
47+
const osmium::io::File output_file{output_file_name, output_file_name == "-" ? ".opl" : ""};
4848

4949
try {
5050
// Create a buffer where all objects will live. Use a sensible initial

examples/osmium_debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
4343
// Get entity types from command line if there is a 2nd argument.
4444
if (argc == 3) {
4545
read_types = osmium::osm_entity_bits::nothing;
46-
std::string types = argv[2];
46+
const std::string types = argv[2];
4747
if (types.find('n') != std::string::npos) {
4848
read_types |= osmium::osm_entity_bits::node;
4949
}

examples/osmium_dump_internal.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,31 @@ int main(int argc, char* argv[]) {
165165
reader.close();
166166

167167
// Write out node, way, and relation offset indexes to disk.
168-
IndexFile nodes_idx{output_dir + "/nodes.idx"};
168+
const IndexFile nodes_idx{output_dir + "/nodes.idx"};
169169
node_index.dump_as_list(nodes_idx.fd());
170170

171-
IndexFile ways_idx{output_dir + "/ways.idx"};
171+
const IndexFile ways_idx{output_dir + "/ways.idx"};
172172
way_index.dump_as_list(ways_idx.fd());
173173

174-
IndexFile relations_idx{output_dir + "/relations.idx"};
174+
const IndexFile relations_idx{output_dir + "/relations.idx"};
175175
relation_index.dump_as_list(relations_idx.fd());
176176

177177
// Sort the maps (so later binary search will work on them) and write
178178
// them to disk.
179179
map_node2way.sort();
180-
IndexFile node2way_idx{output_dir + "/node2way.map"};
180+
const IndexFile node2way_idx{output_dir + "/node2way.map"};
181181
map_node2way.dump_as_list(node2way_idx.fd());
182182

183183
map_node2relation.sort();
184-
IndexFile node2relation_idx{output_dir + "/node2rel.map"};
184+
const IndexFile node2relation_idx{output_dir + "/node2rel.map"};
185185
map_node2relation.dump_as_list(node2relation_idx.fd());
186186

187187
map_way2relation.sort();
188-
IndexFile way2relation_idx{output_dir + "/way2rel.map"};
188+
const IndexFile way2relation_idx{output_dir + "/way2rel.map"};
189189
map_way2relation.dump_as_list(way2relation_idx.fd());
190190

191191
map_relation2relation.sort();
192-
IndexFile relation2relation_idx{output_dir + "/rel2rel.map"};
192+
const IndexFile relation2relation_idx{output_dir + "/rel2rel.map"};
193193
map_relation2relation.dump_as_list(relation2relation_idx.fd());
194194
} catch (const std::exception& e) {
195195
// All exceptions used by the Osmium library derive from std::exception.

examples/osmium_filter_discussions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ int main(int argc, char* argv[]) {
4747

4848
try {
4949
// The input file, deduce file format from file suffix.
50-
osmium::io::File input_file{argv[1]};
50+
const osmium::io::File input_file{argv[1]};
5151

5252
// The output file, force XML OSM file format.
53-
osmium::io::File output_file{argv[2], "osm"};
53+
const osmium::io::File output_file{argv[2], "osm"};
5454

5555
// Initialize Reader for the input file.
5656
// Read only changesets (will ignore nodes, ways, and

examples/osmium_index_lookup.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class IndexAccessDense : public IndexAccess<TValue> {
106106
~IndexAccessDense() noexcept override = default;
107107

108108
void dump() const override {
109-
index_type index{this->fd()};
109+
const index_type index{this->fd()};
110110

111111
for (std::size_t i = 0; i < index.size(); ++i) {
112112
if (index.get(i) != TValue{}) {
@@ -116,7 +116,7 @@ class IndexAccessDense : public IndexAccess<TValue> {
116116
}
117117

118118
bool search(const osmium::unsigned_object_id_type& key) const override {
119-
index_type index{this->fd()};
119+
const index_type index{this->fd()};
120120

121121
try {
122122
TValue value = index.get(key);
@@ -153,7 +153,7 @@ class IndexAccessSparse : public IndexAccess<TValue> {
153153
~IndexAccessSparse() noexcept override = default;
154154

155155
void dump() const override {
156-
index_type index{this->fd()};
156+
const index_type index{this->fd()};
157157

158158
for (const auto& element : index) {
159159
std::cout << element.first << " " << element.second << "\n";
@@ -164,7 +164,7 @@ class IndexAccessSparse : public IndexAccess<TValue> {
164164
using element_type = typename index_type::element_type;
165165
index_type index{this->fd()};
166166

167-
element_type elem{key, TValue{}};
167+
const element_type elem{key, TValue{}};
168168
const auto positions = std::equal_range(index.begin(),
169169
index.end(),
170170
elem,
@@ -347,7 +347,7 @@ int run(const IndexAccess<TValue>& index, const Options& options) {
347347

348348
int main(int argc, char* argv[]) {
349349
// Parse command line options.
350-
Options options{argc, argv};
350+
const Options options{argc, argv};
351351

352352
// Open the index file.
353353
const int fd = ::open(options.filename(), O_RDWR);

0 commit comments

Comments
 (0)