LCOV - code coverage report
Current view: top level - boost/http_proto/impl/sink.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 95.5 % 22 21
Test Date: 2025-01-06 18:34:48 Functions: 100.0 % 2 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/cppalliance/http_proto
       8              : //
       9              : 
      10              : #ifndef BOOST_HTTP_PROTO_IMPL_SINK_HPP
      11              : #define BOOST_HTTP_PROTO_IMPL_SINK_HPP
      12              : 
      13              : #include <boost/buffers/mutable_buffer.hpp>
      14              : #include <boost/buffers/range.hpp>
      15              : #include <boost/http_proto/detail/except.hpp>
      16              : #include <boost/assert.hpp>
      17              : 
      18              : namespace boost {
      19              : namespace http_proto {
      20              : 
      21              : inline
      22              : auto
      23        61083 : sink::
      24              : results::
      25              : operator+=(
      26              :     results const& rv) noexcept ->
      27              :         results&
      28              : {
      29        61083 :     BOOST_ASSERT(! ec.failed());
      30        61083 :     ec = rv.ec;
      31        61083 :     bytes += rv.bytes;
      32        61083 :     return *this;
      33              : }
      34              : 
      35              : //------------------------------------------------
      36              : 
      37              : template<class T>
      38              : auto
      39        20358 : sink::
      40              : write_impl(
      41              :     T const& bs,
      42              :     bool more) ->
      43              :         results
      44              : {
      45        20358 :     results rv;
      46        20358 :     constexpr int SmallArraySize = 16;
      47        20358 :     buffers::const_buffer tmp[SmallArraySize];
      48        20358 :     auto const tmp_end = tmp + SmallArraySize;
      49        20358 :     auto it = buffers::begin(bs);
      50        20358 :     auto const end_ = buffers::end(bs);
      51        40716 :     while(it != end_)
      52              :     {
      53        20358 :         auto p = tmp;
      54              :         do
      55              :         {
      56        40716 :             *p++ = *it++;
      57              :         }
      58              :         while(
      59        40716 :             p != tmp_end &&
      60              :             it != end_);
      61        20358 :         rv += on_write(
      62              :             buffers::const_buffer_span(
      63        20358 :                 tmp, p - tmp),
      64        20358 :             it != end_ ||
      65              :                 more);
      66        20358 :         if(rv.ec.failed())
      67            0 :             return rv;
      68              :     }
      69        20358 :     return rv;
      70              : }
      71              : 
      72              : } // http_proto
      73              : } // boost
      74              : 
      75              : #endif
        

Generated by: LCOV version 2.1