Skip to content

Commit 0852a3d

Browse files
authored
Merge pull request #1485 from joto/avoid-copy
Move linestring around avoiding a copy
2 parents 9622948 + f54584f commit 0852a3d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/geom.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ void split_linestring(linestring_t const &line, double split_at,
113113
}
114114
}
115115

116-
void make_line(linestring_t const &line, double split_at,
116+
void make_line(linestring_t &&line, double split_at,
117117
std::vector<linestring_t> *out)
118118
{
119+
assert(out);
120+
119121
if (line.empty()) {
120122
return;
121123
}
@@ -237,7 +239,7 @@ void make_multiline(osmium::memory::Buffer const &ways, double split_at,
237239
}
238240

239241
// found a line end, create the wkbs
240-
make_line(linestring, split_at, out);
242+
make_line(std::move(linestring), split_at, out);
241243
}
242244

243245
// If all ways have been "done", i.e. are part of a linestring now, we
@@ -284,7 +286,7 @@ void make_multiline(osmium::memory::Buffer const &ways, double split_at,
284286
}
285287

286288
// found a line end, create the wkbs
287-
make_line(linestring, split_at, out);
289+
make_line(std::move(linestring), split_at, out);
288290
}
289291
}
290292

src/geom.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ operator<<(std::basic_ostream<TChar, TTraits> &out, const linestring_t &line)
140140
void split_linestring(linestring_t const &line, double split_at,
141141
std::vector<linestring_t> *out);
142142

143-
void make_line(linestring_t const &line, double split_at,
143+
void make_line(linestring_t &&line, double split_at,
144144
std::vector<linestring_t> *out);
145145

146146
/**

0 commit comments

Comments
 (0)