Skip to content

Commit 23cbc8c

Browse files
committed
Use std::distance() and std::advance() instead of iterator arithmetic.
1 parent 5999ff5 commit 23cbc8c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

+12-11
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,12 @@ namespace boost { namespace network { namespace http {
229229
{
230230
input_range input = boost::make_iterator_range(new_start, read_buffer_.end());
231231
thread_pool().post(
232-
strand.wrap(
233-
boost::bind(
234-
callback
235-
, input
236-
, boost::system::error_code()
237-
, data_end - new_start
238-
, async_connection<Tag,Handler>::shared_from_this())
239-
)
232+
boost::bind(
233+
callback
234+
, input
235+
, boost::system::error_code()
236+
, std::distance(new_start, data_end)
237+
, async_connection<Tag,Handler>::shared_from_this())
240238
);
241239
new_start = read_buffer_.begin();
242240
return;
@@ -262,11 +260,13 @@ namespace boost { namespace network { namespace http {
262260

263261
void wrap_read_handler(read_callback_function callback, boost::system::error_code const & ec, std::size_t bytes_transferred) {
264262
if (ec) error_encountered = in_place<boost::system::system_error>(ec);
263+
buffer_type::const_iterator data_start = read_buffer_.begin()
264+
,data_end = read_buffer_.begin();
265+
std::advance(data_end, bytes_transferred);
265266
thread_pool().post(
266267
boost::bind(
267268
callback
268-
, boost::make_iterator_range(read_buffer_.begin()
269-
,read_buffer_.begin() + bytes_transferred)
269+
, boost::make_iterator_range(data_start, data_end)
270270
, ec
271271
, bytes_transferred
272272
, async_connection<Tag,Handler>::shared_from_this()));
@@ -334,7 +334,8 @@ namespace boost { namespace network { namespace http {
334334
if (!ec) {
335335
logic::tribool parsed_ok;
336336
iterator_range<buffer_type::iterator> result_range, input_range;
337-
data_end = new_start + bytes_transferred;
337+
data_end = read_buffer_.begin();
338+
std::advance(data_end, bytes_transferred);
338339
switch (state) {
339340
case method:
340341
input_range = boost::make_iterator_range(

0 commit comments

Comments
 (0)