LCOV - code coverage report
Current view: top level - src/detail - array_of_const_buffers.cpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 76.5 % 34 26 8
Test Date: 2026-06-13 19:44:58 Functions: 80.0 % 5 4 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3                 : // Copyright (c) 2025 Mohammad Nejati
       4                 : //
       5                 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6                 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7                 : //
       8                 : // Official repository: https://github.com/cppalliance/http
       9                 : //
      10                 : 
      11                 : #include "src/detail/array_of_const_buffers.hpp"
      12                 : 
      13                 : #include <boost/http/detail/except.hpp>
      14                 : 
      15                 : namespace boost {
      16                 : namespace http {
      17                 : namespace detail {
      18                 : 
      19 HIT         159 : array_of_const_buffers::
      20                 : array_of_const_buffers(
      21                 :     value_type* p,
      22             159 :     std::uint16_t capacity) noexcept
      23             159 :     : base_(p)
      24             159 :     , cap_(capacity)
      25             159 :     , pos_(0)
      26             159 :     , size_(0)
      27                 : {
      28             159 : }
      29                 : 
      30                 : void
      31            1985 : array_of_const_buffers::
      32                 : consume(std::size_t n)
      33                 : {
      34            2162 :     while(size_ > 0)
      35                 :     {
      36            1952 :         auto* p = base_ + pos_;
      37            1952 :         if(n < p->size())
      38                 :         {
      39            1775 :             *p += n;
      40            1775 :             return;
      41                 :         }
      42             177 :         n -= p->size();
      43             177 :         ++pos_;
      44             177 :         --size_;
      45                 :     }
      46                 : }
      47                 : 
      48                 : void
      49             266 : array_of_const_buffers::
      50                 : reset(std::uint16_t n) noexcept
      51                 : {
      52             266 :     BOOST_ASSERT(n <= cap_);
      53             266 :     pos_  = 0;
      54             266 :     size_ = n;
      55             266 : }
      56                 : 
      57                 : void
      58 MIS           0 : array_of_const_buffers::
      59                 : slide_to_front() noexcept
      60                 : {
      61               0 :     auto* p = base_ + pos_; // begin
      62               0 :     auto* e = p + size_; // end
      63               0 :     auto* d = base_; // dest
      64               0 :     while(p < e)
      65               0 :         *d++ = *p++;
      66               0 :     pos_ = 0;
      67               0 : }
      68                 : 
      69                 : void
      70 HIT         327 : array_of_const_buffers::
      71                 : append(value_type buf) noexcept
      72                 : {
      73             327 :     BOOST_ASSERT(size_ < cap_);
      74             327 :     base_[pos_ + size_] = buf;
      75             327 :     ++size_;
      76             327 : }
      77                 : 
      78                 : } // detail
      79                 : } // http
      80                 : } // boost
        

Generated by: LCOV version 2.3