GCC Code Coverage Report


Directory: libs/http_proto/
File: include/boost/http_proto/impl/sink.hpp
Date: 2025-09-21 18:08:15
Exec Total Coverage
Lines: 22 22 100.0%
Functions: 3 3 100.0%
Branches: 12 16 75.0%

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