GCC Code Coverage Report


Directory: libs/http_proto/
File: include/boost/http_proto/impl/sink.hpp
Date: 2025-05-26 06:53:21
Exec Total Coverage
Lines: 21 22 95.5%
Functions: 2 2 100.0%
Branches: 11 16 68.8%

Line Branch Exec Source
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 61173 sink::
24 results::
25 operator+=(
26 results const& rv) noexcept ->
27 results&
28 {
29
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 61173 times.
61173 BOOST_ASSERT(! ec.failed());
30 61173 ec = rv.ec;
31 61173 bytes += rv.bytes;
32 61173 return *this;
33 }
34
35 //------------------------------------------------
36
37 template<class T>
38 auto
39 20388 sink::
40 write_impl(
41 T const& bs,
42 bool more) ->
43 results
44 {
45 20388 results rv;
46 20388 constexpr int SmallArraySize = 16;
47 20388 buffers::const_buffer tmp[SmallArraySize];
48 20388 auto const tmp_end = tmp + SmallArraySize;
49 20388 auto it = buffers::begin(bs);
50 20388 auto const end_ = buffers::end(bs);
51
2/2
✓ Branch 0 taken 20388 times.
✓ Branch 1 taken 20388 times.
40776 while(it != end_)
52 {
53 20388 auto p = tmp;
54 do
55 {
56 40776 *p++ = *it++;
57 }
58 while(
59
3/4
✓ Branch 0 taken 40776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20388 times.
✓ Branch 3 taken 20388 times.
40776 p != tmp_end &&
60 it != end_);
61
1/2
✓ Branch 1 taken 20388 times.
✗ Branch 2 not taken.
20388 rv += on_write(
62 buffers::const_buffer_span(
63 20388 tmp, p - tmp),
64
3/4
✓ Branch 0 taken 20388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20060 times.
✓ Branch 3 taken 328 times.
20388 it != end_ ||
65 more);
66
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 20388 times.
20388 if(rv.ec.failed())
67 return rv;
68 }
69 20388 return rv;
70 }
71
72 } // http_proto
73 } // boost
74
75 #endif
76