LCOV - code coverage report
Current view: top level - url/grammar/detail - recycled.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 6 6
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 4 4

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2022 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/boostorg/url
       8                 : //
       9                 : 
      10                 : #ifndef BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
      11                 : #define BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
      12                 : 
      13                 : #include <utility>
      14                 : 
      15                 : namespace boost {
      16                 : namespace urls {
      17                 : namespace grammar {
      18                 : namespace implementation_defined {
      19                 : 
      20                 : template<
      21                 :     std::size_t Size,
      22                 :     std::size_t Align>
      23                 : struct aligned_storage_impl
      24                 : {
      25 HIT          38 :     void* addr() noexcept
      26                 :     {
      27              38 :         return buf_;
      28                 :     }
      29                 : 
      30                 :     void const* addr() const noexcept
      31                 :     {
      32                 :         return buf_;
      33                 :     }
      34                 : 
      35                 : private:
      36                 :     alignas(Align)
      37                 :     unsigned char buf_[Size];
      38                 : };
      39                 : 
      40                 : constexpr
      41                 : std::size_t
      42                 : nearest_pow2(
      43                 :     std::size_t x,
      44                 :     std::size_t f = 0) noexcept
      45                 : {
      46                 :     return
      47                 :         (f <= (std::size_t(-1)/2))
      48                 :         ? ( x <= f
      49                 :             ? f
      50                 :             : nearest_pow2(x, 2 * f))
      51                 :         : x;
      52                 : }
      53                 : 
      54                 : //------------------------------------------------
      55                 : 
      56                 : BOOST_URL_DECL
      57                 : void
      58                 : recycled_add_impl(
      59                 :     std::size_t) noexcept;
      60                 : 
      61                 : BOOST_URL_DECL
      62                 : void
      63                 : recycled_remove_impl(
      64                 :     std::size_t) noexcept;
      65                 : 
      66                 : #ifdef BOOST_URL_REPORT
      67                 : 
      68                 : inline
      69                 : void
      70                 : recycled_add(
      71                 :     std::size_t n) noexcept
      72                 : {
      73                 :     recycled_add_impl(n);
      74                 : }
      75                 : 
      76                 : inline
      77                 : void
      78                 : recycled_remove(
      79                 :     std::size_t n) noexcept
      80                 : {
      81                 :     recycled_remove_impl(n);
      82                 : }
      83                 : 
      84                 : #else
      85                 : 
      86              14 : inline void recycled_add(
      87                 :     std::size_t) noexcept
      88                 : {
      89              14 : }
      90              12 : inline void recycled_remove(
      91                 :     std::size_t) noexcept
      92                 : {
      93              12 : }
      94                 : 
      95                 : #endif
      96                 : 
      97                 : } // implementation_defined
      98                 : } // grammar
      99                 : } // urls
     100                 : } // boost
     101                 : 
     102                 : #endif
        

Generated by: LCOV version 2.3