Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021 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 | #include <boost/http_proto/rfc/combine_field_values.hpp> | ||
11 | |||
12 | namespace boost { | ||
13 | namespace http_proto { | ||
14 | |||
15 | core::string_view | ||
16 | 8 | combine_field_values( | |
17 | fields_view_base::subrange const& vr, | ||
18 | grammar::recycled_ptr<std::string>& temp) | ||
19 | { | ||
20 | 8 | core::string_view result; | |
21 | 8 | bool acquired = false; | |
22 |
2/2✓ Branch 5 taken 11 times.
✓ Branch 6 taken 8 times.
|
19 | for(auto s : vr) |
23 | { | ||
24 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
|
11 | if(s.empty()) |
25 | ✗ | continue; | |
26 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 2 taken 4 times.
|
11 | if(result.empty()) |
27 | { | ||
28 | 7 | result = s; | |
29 | } | ||
30 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | else if(! acquired) |
31 | { | ||
32 | 3 | acquired = true; | |
33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if(temp.empty()) |
34 | ✗ | temp.acquire(); | |
35 | 3 | temp->clear(); | |
36 | 3 | temp->reserve( | |
37 | 3 | result.size() + | |
38 |
1/2✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | 1 + s.size()); |
39 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | *temp = result; |
40 |
1/2✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | temp->push_back(','); |
41 |
1/2✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | temp->append( |
42 | s.data(), s.size()); | ||
43 | 3 | result = *temp; | |
44 | } | ||
45 | else | ||
46 | { | ||
47 | 1 | temp->reserve( | |
48 | 1 | temp->size() + | |
49 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | 1 + s.size()); |
50 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | temp->push_back(','); |
51 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | temp->append( |
52 | s.data(), s.size()); | ||
53 | 1 | result = *temp; | |
54 | } | ||
55 | } | ||
56 | 8 | return result; | |
57 | } | ||
58 | |||
59 | } // http_proto | ||
60 | } // boost | ||
61 |