Skip to content

Commit 02d6e81

Browse files
committed
Use std::distance() and std::advance() instead of iterator arithmetic.
1 parent a2fb9fe commit 02d6e81

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

boost/network/protocol/http/server/async_connection.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,12 @@ namespace boost { namespace network { namespace http {
231231
{
232232
input_range input = boost::make_iterator_range(new_start, read_buffer_.end());
233233
thread_pool().post(
234-
strand.wrap(
235-
boost::bind(
236-
callback
237-
, input
238-
, boost::system::error_code()
239-
, data_end - new_start
240-
, async_connection<Tag,Handler>::shared_from_this())
241-
)
234+
boost::bind(
235+
callback
236+
, input
237+
, boost::system::error_code()
238+
, std::distance(new_start, data_end)
239+
, async_connection<Tag,Handler>::shared_from_this())
242240
);
243241
new_start = read_buffer_.begin();
244242
return;
@@ -264,11 +262,13 @@ namespace boost { namespace network { namespace http {
264262

265263
void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) {
266264
if (ec) error_encountered = in_place<boost::system::system_error>(ec);
265+
buffer_type::const_iterator data_start = read_buffer_.begin()
266+
,data_end = read_buffer_.begin();
267+
std::advance(data_end, bytes_transferred);
267268
thread_pool().post(
268269
boost::bind(
269270
callback
270-
, boost::make_iterator_range(read_buffer_.begin()
271-
,read_buffer_.begin() + bytes_transferred)
271+
, boost::make_iterator_range(data_start, data_end)
272272
, ec
273273
, bytes_transferred
274274
, async_connection<Tag,Handler>::shared_from_this()));
@@ -336,7 +336,8 @@ namespace boost { namespace network { namespace http {
336336
if (!ec) {
337337
logic::tribool parsed_ok;
338338
iterator_range<buffer_type::iterator> result_range, input_range;
339-
data_end = new_start + bytes_transferred;
339+
data_end = read_buffer_.begin();
340+
std::advance(data_end, bytes_transferred);
340341
switch (state) {
341342
case method:
342343
input_range = boost::make_iterator_range(

0 commit comments

Comments
 (0)