LCOV - code coverage report
Current view: top level - libs/buffers/src - buffer_pair.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 44 44
Test Date: 2025-12-06 02:12:43 Functions: 100.0 % 2 2

            Line data    Source code
       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/buffers
       8              : //
       9              : 
      10              : #include <boost/buffers/buffer_pair.hpp>
      11              : #include <boost/buffers/slice.hpp>
      12              : 
      13              : namespace boost {
      14              : namespace buffers {
      15              : 
      16              : void
      17       267280 : tag_invoke(
      18              :     slice_tag const&,
      19              :     const_buffer_pair& bs,
      20              :     slice_how how,
      21              :     std::size_t n) noexcept
      22              : {
      23       267280 :     switch(how)
      24              :     {
      25       131584 :     case slice_how::remove_prefix:
      26              :     {
      27       131584 :         auto p = &bs[0];
      28       131584 :         if(n < p->size())
      29              :         {
      30        71969 :             remove_prefix(*p, n);
      31        71969 :             return;
      32              :         }
      33        59615 :         n -= p->size();
      34        59615 :         *p = bs[1];
      35        59615 :         bs[1] = {};
      36        59615 :         remove_prefix(*p, n);
      37        59615 :         return;
      38              :     }
      39              : 
      40       135696 :     case slice_how::keep_prefix:
      41              :     {
      42       135696 :         auto p = &bs[0];
      43       135696 :         if(n <= p->size())
      44              :         {
      45        87455 :             keep_prefix(*p, n);
      46        87455 :             bs[1] = {};
      47        87455 :             return;
      48              :         }
      49        48241 :         n -= p->size();
      50        48241 :         ++p;
      51        48241 :         keep_prefix(*p, n);
      52        48241 :         return;
      53              :     }
      54              :     }
      55              : }
      56              : 
      57              : void
      58         1040 : tag_invoke(
      59              :     slice_tag const&,
      60              :     mutable_buffer_pair& bs,
      61              :     slice_how how,
      62              :     std::size_t n) noexcept
      63              : {
      64         1040 :     switch(how)
      65              :     {
      66          512 :     case slice_how::remove_prefix:
      67              :     {
      68          512 :         auto p = &bs[0];
      69          512 :         if(n < p->size())
      70              :         {
      71          225 :             remove_prefix(*p, n);
      72          225 :             return;
      73              :         }
      74          287 :         n -= p->size();
      75          287 :         *p = bs[1];
      76          287 :         bs[1] = {};
      77          287 :         remove_prefix(*p, n);
      78          287 :         return;
      79              :     }
      80              : 
      81          528 :     case slice_how::keep_prefix:
      82              :     {
      83          528 :         auto p = &bs[0];
      84          528 :         if(n <= p->size())
      85              :         {
      86          287 :             keep_prefix(*p, n);
      87          287 :             bs[1] = {};
      88          287 :             return;
      89              :         }
      90          241 :         n -= p->size();
      91          241 :         ++p;
      92          241 :         keep_prefix(*p, n);
      93          241 :         return;
      94              :     }
      95              :     }
      96              : }
      97              : 
      98              : } // buffers
      99              : } // boost
        

Generated by: LCOV version 2.1