92.59% Lines (25/27)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/http | 7 | // Official repository: https://github.com/cppalliance/http | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #include <boost/http/rfc/combine_field_values.hpp> | 10 | #include <boost/http/rfc/combine_field_values.hpp> | |||||
| 11 | 11 | |||||||
| 12 | namespace boost { | 12 | namespace boost { | |||||
| 13 | namespace http { | 13 | namespace http { | |||||
| 14 | 14 | |||||||
| 15 | core::string_view | 15 | core::string_view | |||||
| HITCBC | 16 | 8 | combine_field_values( | 16 | 8 | combine_field_values( | ||
| 17 | fields_base::subrange const& vr, | 17 | fields_base::subrange const& vr, | |||||
| 18 | grammar::recycled_ptr<std::string>& temp) | 18 | grammar::recycled_ptr<std::string>& temp) | |||||
| 19 | { | 19 | { | |||||
| HITCBC | 20 | 8 | core::string_view result; | 20 | 8 | core::string_view result; | ||
| HITCBC | 21 | 8 | bool acquired = false; | 21 | 8 | bool acquired = false; | ||
| HITCBC | 22 | 19 | for(auto s : vr) | 22 | 19 | for(auto s : vr) | ||
| 23 | { | 23 | { | |||||
| HITCBC | 24 | 11 | if(s.empty()) | 24 | 11 | if(s.empty()) | ||
| MISUBC | 25 | ✗ | continue; | 25 | ✗ | continue; | ||
| HITCBC | 26 | 11 | if(result.empty()) | 26 | 11 | if(result.empty()) | ||
| 27 | { | 27 | { | |||||
| HITCBC | 28 | 7 | result = s; | 28 | 7 | result = s; | ||
| 29 | } | 29 | } | |||||
| HITCBC | 30 | 4 | else if(! acquired) | 30 | 4 | else if(! acquired) | ||
| 31 | { | 31 | { | |||||
| HITCBC | 32 | 3 | acquired = true; | 32 | 3 | acquired = true; | ||
| HITCBC | 33 | 3 | if(temp.empty()) | 33 | 3 | if(temp.empty()) | ||
| MISUBC | 34 | ✗ | temp.acquire(); | 34 | ✗ | temp.acquire(); | ||
| HITCBC | 35 | 3 | temp->clear(); | 35 | 3 | temp->clear(); | ||
| HITCBC | 36 | 3 | temp->reserve( | 36 | 3 | temp->reserve( | ||
| HITCBC | 37 | 3 | result.size() + | 37 | 3 | result.size() + | ||
| HITCBC | 38 | 3 | 1 + s.size()); | 38 | 3 | 1 + s.size()); | ||
| HITCBC | 39 | 3 | *temp = result; | 39 | 3 | *temp = result; | ||
| HITCBC | 40 | 3 | temp->push_back(','); | 40 | 3 | temp->push_back(','); | ||
| HITCBC | 41 | 3 | temp->append( | 41 | 3 | temp->append( | ||
| 42 | s.data(), s.size()); | 42 | s.data(), s.size()); | |||||
| HITCBC | 43 | 3 | result = *temp; | 43 | 3 | result = *temp; | ||
| 44 | } | 44 | } | |||||
| 45 | else | 45 | else | |||||
| 46 | { | 46 | { | |||||
| HITCBC | 47 | 1 | temp->reserve( | 47 | 1 | temp->reserve( | ||
| HITCBC | 48 | 1 | temp->size() + | 48 | 1 | temp->size() + | ||
| HITCBC | 49 | 1 | 1 + s.size()); | 49 | 1 | 1 + s.size()); | ||
| HITCBC | 50 | 1 | temp->push_back(','); | 50 | 1 | temp->push_back(','); | ||
| HITCBC | 51 | 1 | temp->append( | 51 | 1 | temp->append( | ||
| 52 | s.data(), s.size()); | 52 | s.data(), s.size()); | |||||
| HITCBC | 53 | 1 | result = *temp; | 53 | 1 | result = *temp; | ||
| 54 | } | 54 | } | |||||
| 55 | } | 55 | } | |||||
| HITCBC | 56 | 8 | return result; | 56 | 8 | return result; | ||
| 57 | } | 57 | } | |||||
| 58 | 58 | |||||||
| 59 | } // http | 59 | } // http | |||||
| 60 | } // boost | 60 | } // boost | |||||