Line | Count | Source |
1 | | // Copyright (c) 2015-present The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_PREVECTOR_H |
6 | | #define BITCOIN_PREVECTOR_H |
7 | | |
8 | | #include <algorithm> |
9 | | #include <cassert> |
10 | | #include <cstddef> |
11 | | #include <cstdint> |
12 | | #include <cstdlib> |
13 | | #include <cstring> |
14 | | #include <iterator> |
15 | | #include <type_traits> |
16 | | #include <utility> |
17 | | |
18 | | /** Implements a drop-in replacement for std::vector<T> which stores up to N |
19 | | * elements directly (without heap allocation). The types Size and Diff are |
20 | | * used to store element counts, and can be any unsigned + signed type. |
21 | | * |
22 | | * Storage layout is either: |
23 | | * - Direct allocation: |
24 | | * - Size _size: the number of used elements (between 0 and N) |
25 | | * - T direct[N]: an array of N elements of type T |
26 | | * (only the first _size are initialized). |
27 | | * - Indirect allocation: |
28 | | * - Size _size: the number of used elements plus N + 1 |
29 | | * - Size capacity: the number of allocated elements |
30 | | * - T* indirect: a pointer to an array of capacity elements of type T |
31 | | * (only the first _size are initialized). |
32 | | * |
33 | | * The data type T must be movable by memmove/realloc(). Once we switch to C++, |
34 | | * move constructors can be used instead. |
35 | | */ |
36 | | template<unsigned int N, typename T, typename Size = uint32_t, typename Diff = int32_t> |
37 | | class prevector { |
38 | | static_assert(std::is_trivially_copyable_v<T>); |
39 | | |
40 | | public: |
41 | | typedef Size size_type; |
42 | | typedef Diff difference_type; |
43 | | typedef T value_type; |
44 | | typedef value_type& reference; |
45 | | typedef const value_type& const_reference; |
46 | | typedef value_type* pointer; |
47 | | typedef const value_type* const_pointer; |
48 | | |
49 | | class iterator { |
50 | | T* ptr{}; |
51 | | public: |
52 | | typedef Diff difference_type; |
53 | | typedef T* pointer; |
54 | | typedef T& reference; |
55 | | using element_type = T; |
56 | | using iterator_category = std::contiguous_iterator_tag; |
57 | | iterator() = default; |
58 | 51.8M | iterator(T* ptr_) : ptr(ptr_) {} prevector<16u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Line | Count | Source | 58 | 22.6M | iterator(T* ptr_) : ptr(ptr_) {} |
prevector<28u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Line | Count | Source | 58 | 29.2M | iterator(T* ptr_) : ptr(ptr_) {} |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::iterator::iterator(unsigned char*) |
59 | 70.9M | T& operator*() const { return *ptr; } prevector<28u, unsigned char, unsigned int, int>::iterator::operator*() const Line | Count | Source | 59 | 25.6M | T& operator*() const { return *ptr; } |
prevector<16u, unsigned char, unsigned int, int>::iterator::operator*() const Line | Count | Source | 59 | 45.2M | T& operator*() const { return *ptr; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator*() const Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::iterator::operator*() const |
60 | 0 | T* operator->() const { return ptr; } Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<28u, unsigned char, unsigned int, int>::iterator::operator->() const Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::iterator::operator->() const |
61 | | T& operator[](size_type pos) const { return ptr[pos]; } |
62 | 5.10M | iterator& operator++() { ptr++; return *this; } |
63 | | iterator& operator--() { ptr--; return *this; } |
64 | | iterator operator++(int) { iterator copy(*this); ++(*this); return copy; } |
65 | | iterator operator--(int) { iterator copy(*this); --(*this); return copy; } |
66 | 16.9M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } operator-(prevector<28u, unsigned char, unsigned int, int>::iterator, prevector<28u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 66 | 9.41M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
operator-(prevector<16u, unsigned char, unsigned int, int>::iterator, prevector<16u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 66 | 7.54M | difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); } |
Unexecuted instantiation: operator-(prevector<33u, unsigned char, unsigned int, int>::iterator, prevector<33u, unsigned char, unsigned int, int>::iterator) Unexecuted instantiation: operator-(prevector<35u, unsigned char, unsigned int, int>::iterator, prevector<35u, unsigned char, unsigned int, int>::iterator) |
67 | | iterator operator+(size_type n) const { return iterator(ptr + n); } |
68 | | iterator friend operator+(size_type n, iterator x) { return x + n; } |
69 | | iterator& operator+=(size_type n) { ptr += n; return *this; } |
70 | | iterator operator-(size_type n) const { return iterator(ptr - n); } |
71 | | iterator& operator-=(size_type n) { ptr -= n; return *this; } |
72 | | bool operator==(iterator x) const { return ptr == x.ptr; } |
73 | 7.33M | bool operator!=(iterator x) const { return ptr != x.ptr; } |
74 | | bool operator>=(iterator x) const { return ptr >= x.ptr; } |
75 | | bool operator<=(iterator x) const { return ptr <= x.ptr; } |
76 | | bool operator>(iterator x) const { return ptr > x.ptr; } |
77 | | bool operator<(iterator x) const { return ptr < x.ptr; } |
78 | | }; |
79 | | |
80 | | class const_iterator { |
81 | | const T* ptr{}; |
82 | | public: |
83 | | typedef Diff difference_type; |
84 | | typedef const T* pointer; |
85 | | typedef const T& reference; |
86 | | using element_type = const T; |
87 | | using iterator_category = std::contiguous_iterator_tag; |
88 | | const_iterator() = default; |
89 | 219M | const_iterator(const T* ptr_) : ptr(ptr_) {} prevector<16u, unsigned char, unsigned int, int>::const_iterator::const_iterator(unsigned char const*) Line | Count | Source | 89 | 63.3M | const_iterator(const T* ptr_) : ptr(ptr_) {} |
prevector<28u, unsigned char, unsigned int, int>::const_iterator::const_iterator(unsigned char const*) Line | Count | Source | 89 | 155M | const_iterator(const T* ptr_) : ptr(ptr_) {} |
|
90 | 5.47k | const_iterator(iterator x) : ptr(&(*x)) {} |
91 | 8.79G | const T& operator*() const { return *ptr; } prevector<28u, unsigned char, unsigned int, int>::const_iterator::operator*() const Line | Count | Source | 91 | 8.66G | const T& operator*() const { return *ptr; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator*() const Line | Count | Source | 91 | 126M | const T& operator*() const { return *ptr; } |
|
92 | 0 | const T* operator->() const { return ptr; } Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator->() const Unexecuted instantiation: prevector<28u, unsigned char, unsigned int, int>::const_iterator::operator->() const |
93 | 73.7k | const T& operator[](size_type pos) const { return ptr[pos]; } |
94 | 8.56G | const_iterator& operator++() { ptr++; return *this; } prevector<28u, unsigned char, unsigned int, int>::const_iterator::operator++() Line | Count | Source | 94 | 8.44G | const_iterator& operator++() { ptr++; return *this; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator++() Line | Count | Source | 94 | 122M | const_iterator& operator++() { ptr++; return *this; } |
|
95 | 0 | const_iterator& operator--() { ptr--; return *this; } |
96 | 28.5M | const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; } |
97 | | const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; } |
98 | 79.2M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } operator-(prevector<16u, unsigned char, unsigned int, int>::const_iterator, prevector<16u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 98 | 122k | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
operator-(prevector<28u, unsigned char, unsigned int, int>::const_iterator, prevector<28u, unsigned char, unsigned int, int>::const_iterator) Line | Count | Source | 98 | 79.1M | difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); } |
|
99 | 1.62M | const_iterator operator+(size_type n) const { return const_iterator(ptr + n); } |
100 | | const_iterator friend operator+(size_type n, const_iterator x) { return x + n; } |
101 | 23.2M | const_iterator& operator+=(size_type n) { ptr += n; return *this; } |
102 | 0 | const_iterator operator-(size_type n) const { return const_iterator(ptr - n); } |
103 | | const_iterator& operator-=(size_type n) { ptr -= n; return *this; } |
104 | 11.0k | bool operator==(const_iterator x) const { return ptr == x.ptr; } prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator==(prevector<16u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 104 | 11.0k | bool operator==(const_iterator x) const { return ptr == x.ptr; } |
Unexecuted instantiation: prevector<28u, unsigned char, unsigned int, int>::const_iterator::operator==(prevector<28u, unsigned char, unsigned int, int>::const_iterator) const |
105 | 8.56G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } prevector<28u, unsigned char, unsigned int, int>::const_iterator::operator!=(prevector<28u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 105 | 8.41G | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
prevector<16u, unsigned char, unsigned int, int>::const_iterator::operator!=(prevector<16u, unsigned char, unsigned int, int>::const_iterator) const Line | Count | Source | 105 | 152M | bool operator!=(const_iterator x) const { return ptr != x.ptr; } |
|
106 | 28.5M | bool operator>=(const_iterator x) const { return ptr >= x.ptr; } |
107 | | bool operator<=(const_iterator x) const { return ptr <= x.ptr; } |
108 | | bool operator>(const_iterator x) const { return ptr > x.ptr; } |
109 | 43.6M | bool operator<(const_iterator x) const { return ptr < x.ptr; } |
110 | | }; |
111 | | |
112 | | private: |
113 | | #pragma pack(push, 1) |
114 | | union direct_or_indirect { |
115 | | char direct[sizeof(T) * N]; |
116 | | struct { |
117 | | char* indirect; |
118 | | size_type capacity; |
119 | | } indirect_contents; |
120 | | }; |
121 | | #pragma pack(pop) |
122 | | alignas(char*) direct_or_indirect _union = {}; |
123 | | size_type _size = 0; |
124 | | |
125 | | static_assert(alignof(char*) % alignof(size_type) == 0 && sizeof(char*) % alignof(size_type) == 0, "size_type cannot have more restrictive alignment requirement than pointer"); |
126 | | static_assert(alignof(char*) % alignof(T) == 0, "value_type T cannot have more restrictive alignment requirement than pointer"); |
127 | | |
128 | 144M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } prevector<28u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 128 | 53.0M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 128 | 91.4M | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
prevector<33u, unsigned char, unsigned int, int>::direct_ptr(int) Line | Count | Source | 128 | 4.97k | T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::direct_ptr(int) |
129 | 186M | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } prevector<28u, unsigned char, unsigned int, int>::direct_ptr(int) const Line | Count | Source | 129 | 83.1M | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::direct_ptr(int) const Line | Count | Source | 129 | 102M | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
prevector<33u, unsigned char, unsigned int, int>::direct_ptr(int) const Line | Count | Source | 129 | 353 | const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } |
|
130 | 15.4M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } prevector<28u, unsigned char, unsigned int, int>::indirect_ptr(int) Line | Count | Source | 130 | 15.4M | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::indirect_ptr(int) Line | Count | Source | 130 | 66 | T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::indirect_ptr(int) Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::indirect_ptr(int) |
131 | 159M | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } prevector<28u, unsigned char, unsigned int, int>::indirect_ptr(int) const Line | Count | Source | 131 | 159M | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
prevector<16u, unsigned char, unsigned int, int>::indirect_ptr(int) const Line | Count | Source | 131 | 24 | const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect_contents.indirect) + pos; } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::indirect_ptr(int) const |
132 | 1.39G | bool is_direct() const { return _size <= N; } prevector<28u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 132 | 946M | bool is_direct() const { return _size <= N; } |
prevector<16u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 132 | 450M | bool is_direct() const { return _size <= N; } |
prevector<33u, unsigned char, unsigned int, int>::is_direct() const Line | Count | Source | 132 | 2.27M | bool is_direct() const { return _size <= N; } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::is_direct() const |
133 | | |
134 | 112M | void change_capacity(size_type new_capacity) { |
135 | 112M | if (new_capacity <= N) { Branch (135:13): [True: 38.0M, False: 13.3M]
Branch (135:13): [True: 61.1M, False: 33]
Branch (135:13): [True: 353, False: 0]
Branch (135:13): [True: 0, False: 0]
|
136 | 99.2M | if (!is_direct()) { Branch (136:17): [True: 434k, False: 37.6M]
Branch (136:17): [True: 0, False: 61.1M]
Branch (136:17): [True: 0, False: 353]
Branch (136:17): [True: 0, False: 0]
|
137 | 434k | T* indirect = indirect_ptr(0); |
138 | 434k | T* src = indirect; |
139 | 434k | T* dst = direct_ptr(0); |
140 | 434k | memcpy(dst, src, size() * sizeof(T)); |
141 | 434k | free(indirect); |
142 | 434k | _size -= N + 1; |
143 | 434k | } |
144 | 99.2M | } else { |
145 | 13.3M | if (!is_direct()) { Branch (145:17): [True: 322, False: 13.3M]
Branch (145:17): [True: 0, False: 33]
Branch (145:17): [True: 0, False: 0]
Branch (145:17): [True: 0, False: 0]
|
146 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert |
147 | | success. These should instead use an allocator or new/delete so that handlers |
148 | | are called as necessary, but performance would be slightly degraded by doing so. */ |
149 | 322 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); |
150 | 322 | assert(_union.indirect_contents.indirect); Branch (150:17): [True: 322, False: 0]
Branch (150:17): [True: 0, False: 0]
Branch (150:17): [True: 0, False: 0]
Branch (150:17): [True: 0, False: 0]
|
151 | 322 | _union.indirect_contents.capacity = new_capacity; |
152 | 13.3M | } else { |
153 | 13.3M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); |
154 | 13.3M | assert(new_indirect); Branch (154:17): [True: 13.3M, False: 18.4E]
Branch (154:17): [True: 33, False: 0]
Branch (154:17): [True: 0, False: 0]
Branch (154:17): [True: 0, False: 0]
|
155 | 13.3M | T* src = direct_ptr(0); |
156 | 13.3M | T* dst = reinterpret_cast<T*>(new_indirect); |
157 | 13.3M | memcpy(dst, src, size() * sizeof(T)); |
158 | 13.3M | _union.indirect_contents.indirect = new_indirect; |
159 | 13.3M | _union.indirect_contents.capacity = new_capacity; |
160 | 13.3M | _size += N + 1; |
161 | 13.3M | } |
162 | 13.3M | } |
163 | 112M | } prevector<28u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 134 | 51.4M | void change_capacity(size_type new_capacity) { | 135 | 51.4M | if (new_capacity <= N) { Branch (135:13): [True: 38.0M, False: 13.3M]
| 136 | 38.0M | if (!is_direct()) { Branch (136:17): [True: 434k, False: 37.6M]
| 137 | 434k | T* indirect = indirect_ptr(0); | 138 | 434k | T* src = indirect; | 139 | 434k | T* dst = direct_ptr(0); | 140 | 434k | memcpy(dst, src, size() * sizeof(T)); | 141 | 434k | free(indirect); | 142 | 434k | _size -= N + 1; | 143 | 434k | } | 144 | 38.0M | } else { | 145 | 13.3M | if (!is_direct()) { Branch (145:17): [True: 322, False: 13.3M]
| 146 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 147 | | success. These should instead use an allocator or new/delete so that handlers | 148 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 149 | 322 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 150 | 322 | assert(_union.indirect_contents.indirect); Branch (150:17): [True: 322, False: 0]
| 151 | 322 | _union.indirect_contents.capacity = new_capacity; | 152 | 13.3M | } else { | 153 | 13.3M | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 154 | 13.3M | assert(new_indirect); Branch (154:17): [True: 13.3M, False: 18.4E]
| 155 | 13.3M | T* src = direct_ptr(0); | 156 | 13.3M | T* dst = reinterpret_cast<T*>(new_indirect); | 157 | 13.3M | memcpy(dst, src, size() * sizeof(T)); | 158 | 13.3M | _union.indirect_contents.indirect = new_indirect; | 159 | 13.3M | _union.indirect_contents.capacity = new_capacity; | 160 | 13.3M | _size += N + 1; | 161 | 13.3M | } | 162 | 13.3M | } | 163 | 51.4M | } |
prevector<16u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 134 | 61.1M | void change_capacity(size_type new_capacity) { | 135 | 61.1M | if (new_capacity <= N) { Branch (135:13): [True: 61.1M, False: 33]
| 136 | 61.1M | if (!is_direct()) { Branch (136:17): [True: 0, False: 61.1M]
| 137 | 0 | T* indirect = indirect_ptr(0); | 138 | 0 | T* src = indirect; | 139 | 0 | T* dst = direct_ptr(0); | 140 | 0 | memcpy(dst, src, size() * sizeof(T)); | 141 | 0 | free(indirect); | 142 | 0 | _size -= N + 1; | 143 | 0 | } | 144 | 61.1M | } else { | 145 | 33 | if (!is_direct()) { Branch (145:17): [True: 0, False: 33]
| 146 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 147 | | success. These should instead use an allocator or new/delete so that handlers | 148 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 149 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 150 | 0 | assert(_union.indirect_contents.indirect); Branch (150:17): [True: 0, False: 0]
| 151 | 0 | _union.indirect_contents.capacity = new_capacity; | 152 | 33 | } else { | 153 | 33 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 154 | 33 | assert(new_indirect); Branch (154:17): [True: 33, False: 0]
| 155 | 33 | T* src = direct_ptr(0); | 156 | 33 | T* dst = reinterpret_cast<T*>(new_indirect); | 157 | 33 | memcpy(dst, src, size() * sizeof(T)); | 158 | 33 | _union.indirect_contents.indirect = new_indirect; | 159 | 33 | _union.indirect_contents.capacity = new_capacity; | 160 | 33 | _size += N + 1; | 161 | 33 | } | 162 | 33 | } | 163 | 61.1M | } |
prevector<33u, unsigned char, unsigned int, int>::change_capacity(unsigned int) Line | Count | Source | 134 | 353 | void change_capacity(size_type new_capacity) { | 135 | 353 | if (new_capacity <= N) { Branch (135:13): [True: 353, False: 0]
| 136 | 353 | if (!is_direct()) { Branch (136:17): [True: 0, False: 353]
| 137 | 0 | T* indirect = indirect_ptr(0); | 138 | 0 | T* src = indirect; | 139 | 0 | T* dst = direct_ptr(0); | 140 | 0 | memcpy(dst, src, size() * sizeof(T)); | 141 | 0 | free(indirect); | 142 | 0 | _size -= N + 1; | 143 | 0 | } | 144 | 353 | } else { | 145 | 0 | if (!is_direct()) { Branch (145:17): [True: 0, False: 0]
| 146 | | /* FIXME: Because malloc/realloc here won't call new_handler if allocation fails, assert | 147 | | success. These should instead use an allocator or new/delete so that handlers | 148 | | are called as necessary, but performance would be slightly degraded by doing so. */ | 149 | 0 | _union.indirect_contents.indirect = static_cast<char*>(realloc(_union.indirect_contents.indirect, ((size_t)sizeof(T)) * new_capacity)); | 150 | 0 | assert(_union.indirect_contents.indirect); Branch (150:17): [True: 0, False: 0]
| 151 | 0 | _union.indirect_contents.capacity = new_capacity; | 152 | 0 | } else { | 153 | 0 | char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity)); | 154 | 0 | assert(new_indirect); Branch (154:17): [True: 0, False: 0]
| 155 | 0 | T* src = direct_ptr(0); | 156 | 0 | T* dst = reinterpret_cast<T*>(new_indirect); | 157 | 0 | memcpy(dst, src, size() * sizeof(T)); | 158 | 0 | _union.indirect_contents.indirect = new_indirect; | 159 | 0 | _union.indirect_contents.capacity = new_capacity; | 160 | 0 | _size += N + 1; | 161 | 0 | } | 162 | 0 | } | 163 | 353 | } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::change_capacity(unsigned int) |
164 | | |
165 | 145M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } prevector<28u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 165 | 54.2M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (165:47): [True: 39.2M, False: 14.9M]
|
prevector<16u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 165 | 91.4M | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (165:47): [True: 91.4M, False: 56]
|
prevector<33u, unsigned char, unsigned int, int>::item_ptr(int) Line | Count | Source | 165 | 4.97k | T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (165:47): [True: 4.97k, False: 0]
|
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::item_ptr(int) Branch (165:47): [True: 39.2M, False: 14.9M]
Branch (165:47): [True: 91.4M, False: 56]
Branch (165:47): [True: 4.97k, False: 0]
Branch (165:47): [True: 0, False: 0]
|
166 | 345M | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } prevector<28u, unsigned char, unsigned int, int>::item_ptr(int) const Line | Count | Source | 166 | 242M | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (166:59): [True: 83.1M, False: 159M]
|
prevector<16u, unsigned char, unsigned int, int>::item_ptr(int) const Line | Count | Source | 166 | 102M | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (166:59): [True: 102M, False: 31]
|
prevector<33u, unsigned char, unsigned int, int>::item_ptr(int) const Line | Count | Source | 166 | 353 | const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); } Branch (166:59): [True: 353, False: 0]
|
Branch (166:59): [True: 83.1M, False: 159M]
Branch (166:59): [True: 102M, False: 31]
Branch (166:59): [True: 353, False: 0]
|
167 | | |
168 | 31.4M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { |
169 | 31.4M | std::fill_n(dst, count, value); |
170 | 31.4M | } prevector<28u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Line | Count | Source | 168 | 29.5k | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 169 | 29.5k | std::fill_n(dst, count, value); | 170 | 29.5k | } |
prevector<16u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Line | Count | Source | 168 | 31.4M | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 169 | 31.4M | std::fill_n(dst, count, value); | 170 | 31.4M | } |
prevector<33u, unsigned char, unsigned int, int>::fill(unsigned char*, long, unsigned char const&) Line | Count | Source | 168 | 1.42k | void fill(T* dst, ptrdiff_t count, const T& value = T{}) { | 169 | 1.42k | std::fill_n(dst, count, value); | 170 | 1.42k | } |
|
171 | | |
172 | | template <std::input_iterator InputIterator> |
173 | 54.3M | void fill(T* dst, InputIterator first, InputIterator last) { |
174 | 8.49G | while (first != last) { Branch (174:16): [True: 112, False: 56]
Branch (174:16): [True: 36.7M, False: 3.43M]
Branch (174:16): [True: 121M, False: 29.8M]
Branch (174:16): [True: 8.24G, False: 13.4M]
Branch (174:16): [True: 263k, False: 12.7k]
Branch (174:16): [True: 475k, False: 193k]
Branch (174:16): [True: 812k, False: 117k]
Branch (174:16): [True: 114k, False: 11.4k]
Branch (174:16): [True: 0, False: 0]
Branch (174:16): [True: 29.2M, False: 7.30M]
Branch (174:16): [True: 0, False: 0]
Branch (174:16): [True: 0, False: 0]
Branch (174:16): [True: 0, False: 0]
Branch (174:16): [True: 0, False: 0]
|
175 | 8.43G | new(static_cast<void*>(dst)) T(*first); |
176 | 8.43G | ++dst; |
177 | 8.43G | ++first; |
178 | 8.43G | } |
179 | 54.3M | } _ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Line | Count | Source | 173 | 56 | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 168 | while (first != last) { Branch (174:16): [True: 112, False: 56]
| 175 | 112 | new(static_cast<void*>(dst)) T(*first); | 176 | 112 | ++dst; | 177 | 112 | ++first; | 178 | 112 | } | 179 | 56 | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Line | Count | Source | 173 | 3.43M | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 40.1M | while (first != last) { Branch (174:16): [True: 36.7M, False: 3.43M]
| 175 | 36.7M | new(static_cast<void*>(dst)) T(*first); | 176 | 36.7M | ++dst; | 177 | 36.7M | ++first; | 178 | 36.7M | } | 179 | 3.43M | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Line | Count | Source | 173 | 29.8M | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 151M | while (first != last) { Branch (174:16): [True: 121M, False: 29.8M]
| 175 | 121M | new(static_cast<void*>(dst)) T(*first); | 176 | 121M | ++dst; | 177 | 121M | ++first; | 178 | 121M | } | 179 | 29.8M | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorNS0_14const_iteratorEEEvPhT_S4_ Line | Count | Source | 173 | 13.4M | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 8.26G | while (first != last) { Branch (174:16): [True: 8.24G, False: 13.4M]
| 175 | 8.24G | new(static_cast<void*>(dst)) T(*first); | 176 | 8.24G | ++dst; | 177 | 8.24G | ++first; | 178 | 8.24G | } | 179 | 13.4M | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ Line | Count | Source | 173 | 12.7k | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 276k | while (first != last) { Branch (174:16): [True: 263k, False: 12.7k]
| 175 | 263k | new(static_cast<void*>(dst)) T(*first); | 176 | 263k | ++dst; | 177 | 263k | ++first; | 178 | 263k | } | 179 | 12.7k | } |
_ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEEvPhT_SB_ Line | Count | Source | 173 | 193k | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 669k | while (first != last) { Branch (174:16): [True: 475k, False: 193k]
| 175 | 475k | new(static_cast<void*>(dst)) T(*first); | 176 | 475k | ++dst; | 177 | 475k | ++first; | 178 | 475k | } | 179 | 193k | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Line | Count | Source | 173 | 117k | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 930k | while (first != last) { Branch (174:16): [True: 812k, False: 117k]
| 175 | 812k | new(static_cast<void*>(dst)) T(*first); | 176 | 812k | ++dst; | 177 | 812k | ++first; | 178 | 812k | } | 179 | 117k | } |
_ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Line | Count | Source | 173 | 11.4k | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 126k | while (first != last) { Branch (174:16): [True: 114k, False: 11.4k]
| 175 | 114k | new(static_cast<void*>(dst)) T(*first); | 176 | 114k | ++dst; | 177 | 114k | ++first; | 178 | 114k | } | 179 | 11.4k | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvS4_T_S9_ _ZN9prevectorILj16EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Line | Count | Source | 173 | 7.30M | void fill(T* dst, InputIterator first, InputIterator last) { | 174 | 36.5M | while (first != last) { Branch (174:16): [True: 29.2M, False: 7.30M]
| 175 | 29.2M | new(static_cast<void*>(dst)) T(*first); | 176 | 29.2M | ++dst; | 177 | 29.2M | ++first; | 178 | 29.2M | } | 179 | 7.30M | } |
Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvPhT_SA_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPhEEvS2_T_S3_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE4fillITkSt14input_iteratorPKhEEvPhT_S5_ Unexecuted instantiation: _ZN9prevectorILj28EhjiE4fillITkSt14input_iteratorNS0_8iteratorEEEvPhT_S4_ |
180 | | |
181 | | public: |
182 | 373 | void assign(size_type n, const T& val) { |
183 | 373 | clear(); |
184 | 373 | if (capacity() < n) { Branch (184:13): [True: 0, False: 373]
|
185 | 0 | change_capacity(n); |
186 | 0 | } |
187 | 373 | _size += n; |
188 | 373 | fill(item_ptr(0), n, val); |
189 | 373 | } |
190 | | |
191 | | template <std::input_iterator InputIterator> |
192 | 7.68M | void assign(InputIterator first, InputIterator last) { |
193 | 7.68M | size_type n = last - first; |
194 | 7.68M | clear(); |
195 | 7.68M | if (capacity() < n) { Branch (195:13): [True: 0, False: 110k]
Branch (195:13): [True: 133k, False: 0]
Branch (195:13): [True: 0, False: 117k]
Branch (195:13): [True: 0, False: 11.4k]
Branch (195:13): [True: 0, False: 0]
Branch (195:13): [True: 0, False: 7.30M]
|
196 | 133k | change_capacity(n); |
197 | 133k | } |
198 | 7.68M | _size += n; |
199 | 7.68M | fill(item_ptr(0), first, last); |
200 | 7.68M | } _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 192 | 110k | void assign(InputIterator first, InputIterator last) { | 193 | 110k | size_type n = last - first; | 194 | 110k | clear(); | 195 | 110k | if (capacity() < n) { Branch (195:13): [True: 0, False: 110k]
| 196 | 0 | change_capacity(n); | 197 | 0 | } | 198 | 110k | _size += n; | 199 | 110k | fill(item_ptr(0), first, last); | 200 | 110k | } |
_ZN9prevectorILj28EhjiE6assignITkSt14input_iteratorNS0_14const_iteratorEEEvT_S3_ Line | Count | Source | 192 | 133k | void assign(InputIterator first, InputIterator last) { | 193 | 133k | size_type n = last - first; | 194 | 133k | clear(); | 195 | 133k | if (capacity() < n) { Branch (195:13): [True: 133k, False: 0]
| 196 | 133k | change_capacity(n); | 197 | 133k | } | 198 | 133k | _size += n; | 199 | 133k | fill(item_ptr(0), first, last); | 200 | 133k | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvT_S9_ Line | Count | Source | 192 | 117k | void assign(InputIterator first, InputIterator last) { | 193 | 117k | size_type n = last - first; | 194 | 117k | clear(); | 195 | 117k | if (capacity() < n) { Branch (195:13): [True: 0, False: 117k]
| 196 | 0 | change_capacity(n); | 197 | 0 | } | 198 | 117k | _size += n; | 199 | 117k | fill(item_ptr(0), first, last); | 200 | 117k | } |
_ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPhEEvT_S3_ Line | Count | Source | 192 | 11.4k | void assign(InputIterator first, InputIterator last) { | 193 | 11.4k | size_type n = last - first; | 194 | 11.4k | clear(); | 195 | 11.4k | if (capacity() < n) { Branch (195:13): [True: 0, False: 11.4k]
| 196 | 0 | change_capacity(n); | 197 | 0 | } | 198 | 11.4k | _size += n; | 199 | 11.4k | fill(item_ptr(0), first, last); | 200 | 11.4k | } |
Unexecuted instantiation: _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvT_S9_ _ZN9prevectorILj16EhjiE6assignITkSt14input_iteratorPKhEEvT_S4_ Line | Count | Source | 192 | 7.30M | void assign(InputIterator first, InputIterator last) { | 193 | 7.30M | size_type n = last - first; | 194 | 7.30M | clear(); | 195 | 7.30M | if (capacity() < n) { Branch (195:13): [True: 0, False: 7.30M]
| 196 | 0 | change_capacity(n); | 197 | 0 | } | 198 | 7.30M | _size += n; | 199 | 7.30M | fill(item_ptr(0), first, last); | 200 | 7.30M | } |
|
201 | | |
202 | 40.7M | prevector() = default; prevector<28u, unsigned char, unsigned int, int>::prevector() Line | Count | Source | 202 | 38.5M | prevector() = default; |
prevector<33u, unsigned char, unsigned int, int>::prevector() Line | Count | Source | 202 | 2.26M | prevector() = default; |
|
203 | | |
204 | | explicit prevector(size_type n) { |
205 | | resize(n); |
206 | | } |
207 | | |
208 | 31.4M | explicit prevector(size_type n, const T& val) { |
209 | 31.4M | change_capacity(n); |
210 | 31.4M | _size += n; |
211 | 31.4M | fill(item_ptr(0), n, val); |
212 | 31.4M | } prevector<33u, unsigned char, unsigned int, int>::prevector(unsigned int, unsigned char const&) Line | Count | Source | 208 | 353 | explicit prevector(size_type n, const T& val) { | 209 | 353 | change_capacity(n); | 210 | 353 | _size += n; | 211 | 353 | fill(item_ptr(0), n, val); | 212 | 353 | } |
prevector<16u, unsigned char, unsigned int, int>::prevector(unsigned int, unsigned char const&) Line | Count | Source | 208 | 31.4M | explicit prevector(size_type n, const T& val) { | 209 | 31.4M | change_capacity(n); | 210 | 31.4M | _size += n; | 211 | 31.4M | fill(item_ptr(0), n, val); | 212 | 31.4M | } |
|
213 | | |
214 | | template <std::input_iterator InputIterator> |
215 | 207k | prevector(InputIterator first, InputIterator last) { |
216 | 207k | size_type n = last - first; |
217 | 207k | change_capacity(n); |
218 | 207k | _size += n; |
219 | 207k | fill(item_ptr(0), first, last); |
220 | 207k | } _ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEET_S9_ Line | Count | Source | 215 | 12.7k | prevector(InputIterator first, InputIterator last) { | 216 | 12.7k | size_type n = last - first; | 217 | 12.7k | change_capacity(n); | 218 | 12.7k | _size += n; | 219 | 12.7k | fill(item_ptr(0), first, last); | 220 | 12.7k | } |
_ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt6vectorIhSaIhEEEEEET_SA_ Line | Count | Source | 215 | 193k | prevector(InputIterator first, InputIterator last) { | 216 | 193k | size_type n = last - first; | 217 | 193k | change_capacity(n); | 218 | 193k | _size += n; | 219 | 193k | fill(item_ptr(0), first, last); | 220 | 193k | } |
Unexecuted instantiation: _ZN9prevectorILj35EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ Unexecuted instantiation: _ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEET_S9_ _ZN9prevectorILj28EhjiEC2ITkSt14input_iteratorNS0_14const_iteratorEEET_S3_ Line | Count | Source | 215 | 1.61k | prevector(InputIterator first, InputIterator last) { | 216 | 1.61k | size_type n = last - first; | 217 | 1.61k | change_capacity(n); | 218 | 1.61k | _size += n; | 219 | 1.61k | fill(item_ptr(0), first, last); | 220 | 1.61k | } |
|
221 | | |
222 | 42.9M | prevector(const prevector<N, T, Size, Diff>& other) { |
223 | 42.9M | size_type n = other.size(); |
224 | 42.9M | change_capacity(n); |
225 | 42.9M | _size += n; |
226 | 42.9M | fill(item_ptr(0), other.begin(), other.end()); |
227 | 42.9M | } prevector<16u, unsigned char, unsigned int, int>::prevector(prevector<16u, unsigned char, unsigned int, int> const&) Line | Count | Source | 222 | 29.7M | prevector(const prevector<N, T, Size, Diff>& other) { | 223 | 29.7M | size_type n = other.size(); | 224 | 29.7M | change_capacity(n); | 225 | 29.7M | _size += n; | 226 | 29.7M | fill(item_ptr(0), other.begin(), other.end()); | 227 | 29.7M | } |
prevector<28u, unsigned char, unsigned int, int>::prevector(prevector<28u, unsigned char, unsigned int, int> const&) Line | Count | Source | 222 | 13.2M | prevector(const prevector<N, T, Size, Diff>& other) { | 223 | 13.2M | size_type n = other.size(); | 224 | 13.2M | change_capacity(n); | 225 | 13.2M | _size += n; | 226 | 13.2M | fill(item_ptr(0), other.begin(), other.end()); | 227 | 13.2M | } |
|
228 | | |
229 | | prevector(prevector<N, T, Size, Diff>&& other) noexcept |
230 | 8.60M | : _union(std::move(other._union)), _size(other._size) |
231 | 8.60M | { |
232 | 8.60M | other._size = 0; |
233 | 8.60M | } prevector<16u, unsigned char, unsigned int, int>::prevector(prevector<16u, unsigned char, unsigned int, int>&&) Line | Count | Source | 230 | 7.16M | : _union(std::move(other._union)), _size(other._size) | 231 | 7.16M | { | 232 | 7.16M | other._size = 0; | 233 | 7.16M | } |
prevector<28u, unsigned char, unsigned int, int>::prevector(prevector<28u, unsigned char, unsigned int, int>&&) Line | Count | Source | 230 | 1.43M | : _union(std::move(other._union)), _size(other._size) | 231 | 1.43M | { | 232 | 1.43M | other._size = 0; | 233 | 1.43M | } |
|
234 | | |
235 | 244k | prevector& operator=(const prevector<N, T, Size, Diff>& other) { |
236 | 244k | if (&other == this) { Branch (236:13): [True: 0, False: 110k]
Branch (236:13): [True: 0, False: 133k]
|
237 | 0 | return *this; |
238 | 0 | } |
239 | 244k | assign(other.begin(), other.end()); |
240 | 244k | return *this; |
241 | 244k | } prevector<16u, unsigned char, unsigned int, int>::operator=(prevector<16u, unsigned char, unsigned int, int> const&) Line | Count | Source | 235 | 110k | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 236 | 110k | if (&other == this) { Branch (236:13): [True: 0, False: 110k]
| 237 | 0 | return *this; | 238 | 0 | } | 239 | 110k | assign(other.begin(), other.end()); | 240 | 110k | return *this; | 241 | 110k | } |
prevector<28u, unsigned char, unsigned int, int>::operator=(prevector<28u, unsigned char, unsigned int, int> const&) Line | Count | Source | 235 | 133k | prevector& operator=(const prevector<N, T, Size, Diff>& other) { | 236 | 133k | if (&other == this) { Branch (236:13): [True: 0, False: 133k]
| 237 | 0 | return *this; | 238 | 0 | } | 239 | 133k | assign(other.begin(), other.end()); | 240 | 133k | return *this; | 241 | 133k | } |
|
242 | | |
243 | 14.9M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { |
244 | 14.9M | if (!is_direct()) { Branch (244:13): [True: 0, False: 8.27M]
Branch (244:13): [True: 5.27k, False: 6.66M]
|
245 | 5.27k | free(_union.indirect_contents.indirect); |
246 | 5.27k | } |
247 | 14.9M | _union = std::move(other._union); |
248 | 14.9M | _size = other._size; |
249 | 14.9M | other._size = 0; |
250 | 14.9M | return *this; |
251 | 14.9M | } prevector<16u, unsigned char, unsigned int, int>::operator=(prevector<16u, unsigned char, unsigned int, int>&&) Line | Count | Source | 243 | 8.27M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 244 | 8.27M | if (!is_direct()) { Branch (244:13): [True: 0, False: 8.27M]
| 245 | 0 | free(_union.indirect_contents.indirect); | 246 | 0 | } | 247 | 8.27M | _union = std::move(other._union); | 248 | 8.27M | _size = other._size; | 249 | 8.27M | other._size = 0; | 250 | 8.27M | return *this; | 251 | 8.27M | } |
prevector<28u, unsigned char, unsigned int, int>::operator=(prevector<28u, unsigned char, unsigned int, int>&&) Line | Count | Source | 243 | 6.66M | prevector& operator=(prevector<N, T, Size, Diff>&& other) noexcept { | 244 | 6.66M | if (!is_direct()) { Branch (244:13): [True: 5.27k, False: 6.66M]
| 245 | 5.27k | free(_union.indirect_contents.indirect); | 246 | 5.27k | } | 247 | 6.66M | _union = std::move(other._union); | 248 | 6.66M | _size = other._size; | 249 | 6.66M | other._size = 0; | 250 | 6.66M | return *this; | 251 | 6.66M | } |
|
252 | | |
253 | 622M | size_type size() const { |
254 | 622M | return is_direct() ? _size : _size - N - 1; Branch (254:16): [True: 265M, False: 246M]
Branch (254:16): [True: 110M, False: 28]
Branch (254:16): [True: 2.48k, False: 0]
Branch (254:16): [True: 0, False: 0]
|
255 | 622M | } prevector<28u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 253 | 512M | size_type size() const { | 254 | 512M | return is_direct() ? _size : _size - N - 1; Branch (254:16): [True: 265M, False: 246M]
| 255 | 512M | } |
prevector<16u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 253 | 110M | size_type size() const { | 254 | 110M | return is_direct() ? _size : _size - N - 1; Branch (254:16): [True: 110M, False: 28]
| 255 | 110M | } |
prevector<33u, unsigned char, unsigned int, int>::size() const Line | Count | Source | 253 | 2.48k | size_type size() const { | 254 | 2.48k | return is_direct() ? _size : _size - N - 1; Branch (254:16): [True: 2.48k, False: 0]
| 255 | 2.48k | } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::size() const |
256 | | |
257 | 70.8M | bool empty() const { |
258 | 70.8M | return size() == 0; |
259 | 70.8M | } prevector<28u, unsigned char, unsigned int, int>::empty() const Line | Count | Source | 257 | 70.8M | bool empty() const { | 258 | 70.8M | return size() == 0; | 259 | 70.8M | } |
prevector<16u, unsigned char, unsigned int, int>::empty() const Line | Count | Source | 257 | 8.38k | bool empty() const { | 258 | 8.38k | return size() == 0; | 259 | 8.38k | } |
|
260 | | |
261 | 11.2M | iterator begin() { return iterator(item_ptr(0)); } prevector<28u, unsigned char, unsigned int, int>::begin() Line | Count | Source | 261 | 11.2M | iterator begin() { return iterator(item_ptr(0)); } |
Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::begin() Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::begin() Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::begin() |
262 | 90.8M | const_iterator begin() const { return const_iterator(item_ptr(0)); } prevector<28u, unsigned char, unsigned int, int>::begin() const Line | Count | Source | 262 | 57.4M | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
prevector<16u, unsigned char, unsigned int, int>::begin() const Line | Count | Source | 262 | 33.3M | const_iterator begin() const { return const_iterator(item_ptr(0)); } |
|
263 | 27.1M | iterator end() { return iterator(item_ptr(size())); } prevector<28u, unsigned char, unsigned int, int>::end() Line | Count | Source | 263 | 12.0M | iterator end() { return iterator(item_ptr(size())); } |
prevector<16u, unsigned char, unsigned int, int>::end() Line | Count | Source | 263 | 15.0M | iterator end() { return iterator(item_ptr(size())); } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::end() Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::end() |
264 | 126M | const_iterator end() const { return const_iterator(item_ptr(size())); } prevector<28u, unsigned char, unsigned int, int>::end() const Line | Count | Source | 264 | 96.7M | const_iterator end() const { return const_iterator(item_ptr(size())); } |
prevector<16u, unsigned char, unsigned int, int>::end() const Line | Count | Source | 264 | 29.9M | const_iterator end() const { return const_iterator(item_ptr(size())); } |
|
265 | | |
266 | 24.3M | size_t capacity() const { |
267 | 24.3M | if (is_direct()) { Branch (267:13): [True: 16.7M, False: 74.0k]
Branch (267:13): [True: 7.54M, False: 0]
Branch (267:13): [True: 1.06k, False: 0]
Branch (267:13): [True: 0, False: 0]
|
268 | 24.3M | return N; |
269 | 24.3M | } else { |
270 | 74.0k | return _union.indirect_contents.capacity; |
271 | 74.0k | } |
272 | 24.3M | } prevector<28u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 266 | 16.8M | size_t capacity() const { | 267 | 16.8M | if (is_direct()) { Branch (267:13): [True: 16.7M, False: 74.0k]
| 268 | 16.7M | return N; | 269 | 16.7M | } else { | 270 | 74.0k | return _union.indirect_contents.capacity; | 271 | 74.0k | } | 272 | 16.8M | } |
prevector<16u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 266 | 7.54M | size_t capacity() const { | 267 | 7.54M | if (is_direct()) { Branch (267:13): [True: 7.54M, False: 0]
| 268 | 7.54M | return N; | 269 | 7.54M | } else { | 270 | 0 | return _union.indirect_contents.capacity; | 271 | 0 | } | 272 | 7.54M | } |
prevector<33u, unsigned char, unsigned int, int>::capacity() const Line | Count | Source | 266 | 1.06k | size_t capacity() const { | 267 | 1.06k | if (is_direct()) { Branch (267:13): [True: 1.06k, False: 0]
| 268 | 1.06k | return N; | 269 | 1.06k | } else { | 270 | 0 | return _union.indirect_contents.capacity; | 271 | 0 | } | 272 | 1.06k | } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::capacity() const |
273 | | |
274 | 7.64M | T& operator[](size_type pos) { |
275 | 7.64M | return *item_ptr(pos); |
276 | 7.64M | } prevector<28u, unsigned char, unsigned int, int>::operator[](unsigned int) Line | Count | Source | 274 | 7.59M | T& operator[](size_type pos) { | 275 | 7.59M | return *item_ptr(pos); | 276 | 7.59M | } |
prevector<33u, unsigned char, unsigned int, int>::operator[](unsigned int) Line | Count | Source | 274 | 2.13k | T& operator[](size_type pos) { | 275 | 2.13k | return *item_ptr(pos); | 276 | 2.13k | } |
prevector<16u, unsigned char, unsigned int, int>::operator[](unsigned int) Line | Count | Source | 274 | 44.3k | T& operator[](size_type pos) { | 275 | 44.3k | return *item_ptr(pos); | 276 | 44.3k | } |
|
277 | | |
278 | 47.9M | const T& operator[](size_type pos) const { |
279 | 47.9M | return *item_ptr(pos); |
280 | 47.9M | } prevector<16u, unsigned char, unsigned int, int>::operator[](unsigned int) const Line | Count | Source | 278 | 23.5M | const T& operator[](size_type pos) const { | 279 | 23.5M | return *item_ptr(pos); | 280 | 23.5M | } |
prevector<28u, unsigned char, unsigned int, int>::operator[](unsigned int) const Line | Count | Source | 278 | 24.4M | const T& operator[](size_type pos) const { | 279 | 24.4M | return *item_ptr(pos); | 280 | 24.4M | } |
|
281 | | |
282 | 48.2M | void resize(size_type new_size) { |
283 | 48.2M | size_type cur_size = size(); |
284 | 48.2M | if (cur_size == new_size) { Branch (284:13): [True: 40.2M, False: 469k]
Branch (284:13): [True: 133, False: 7.54M]
Branch (284:13): [True: 0, False: 1.06k]
|
285 | 40.2M | return; |
286 | 40.2M | } |
287 | 8.02M | if (cur_size > new_size) { Branch (287:13): [True: 439k, False: 29.5k]
Branch (287:13): [True: 7.54M, False: 33]
Branch (287:13): [True: 0, False: 1.06k]
|
288 | 7.98M | erase(item_ptr(new_size), end()); |
289 | 7.98M | return; |
290 | 7.98M | } |
291 | 30.6k | if (new_size > capacity()) { Branch (291:13): [True: 27.9k, False: 1.60k]
Branch (291:13): [True: 33, False: 0]
Branch (291:13): [True: 0, False: 1.06k]
|
292 | 28.0k | change_capacity(new_size); |
293 | 28.0k | } |
294 | 30.6k | ptrdiff_t increase = new_size - cur_size; |
295 | 30.6k | fill(item_ptr(cur_size), increase); |
296 | 30.6k | _size += increase; |
297 | 30.6k | } prevector<28u, unsigned char, unsigned int, int>::resize(unsigned int) Line | Count | Source | 282 | 40.7M | void resize(size_type new_size) { | 283 | 40.7M | size_type cur_size = size(); | 284 | 40.7M | if (cur_size == new_size) { Branch (284:13): [True: 40.2M, False: 469k]
| 285 | 40.2M | return; | 286 | 40.2M | } | 287 | 469k | if (cur_size > new_size) { Branch (287:13): [True: 439k, False: 29.5k]
| 288 | 439k | erase(item_ptr(new_size), end()); | 289 | 439k | return; | 290 | 439k | } | 291 | 29.5k | if (new_size > capacity()) { Branch (291:13): [True: 27.9k, False: 1.60k]
| 292 | 27.9k | change_capacity(new_size); | 293 | 27.9k | } | 294 | 29.5k | ptrdiff_t increase = new_size - cur_size; | 295 | 29.5k | fill(item_ptr(cur_size), increase); | 296 | 29.5k | _size += increase; | 297 | 29.5k | } |
prevector<16u, unsigned char, unsigned int, int>::resize(unsigned int) Line | Count | Source | 282 | 7.55M | void resize(size_type new_size) { | 283 | 7.55M | size_type cur_size = size(); | 284 | 7.55M | if (cur_size == new_size) { Branch (284:13): [True: 133, False: 7.54M]
| 285 | 133 | return; | 286 | 133 | } | 287 | 7.54M | if (cur_size > new_size) { Branch (287:13): [True: 7.54M, False: 33]
| 288 | 7.54M | erase(item_ptr(new_size), end()); | 289 | 7.54M | return; | 290 | 7.54M | } | 291 | 33 | if (new_size > capacity()) { Branch (291:13): [True: 33, False: 0]
| 292 | 33 | change_capacity(new_size); | 293 | 33 | } | 294 | 33 | ptrdiff_t increase = new_size - cur_size; | 295 | 33 | fill(item_ptr(cur_size), increase); | 296 | 33 | _size += increase; | 297 | 33 | } |
prevector<33u, unsigned char, unsigned int, int>::resize(unsigned int) Line | Count | Source | 282 | 1.06k | void resize(size_type new_size) { | 283 | 1.06k | size_type cur_size = size(); | 284 | 1.06k | if (cur_size == new_size) { Branch (284:13): [True: 0, False: 1.06k]
| 285 | 0 | return; | 286 | 0 | } | 287 | 1.06k | if (cur_size > new_size) { Branch (287:13): [True: 0, False: 1.06k]
| 288 | 0 | erase(item_ptr(new_size), end()); | 289 | 0 | return; | 290 | 0 | } | 291 | 1.06k | if (new_size > capacity()) { Branch (291:13): [True: 0, False: 1.06k]
| 292 | 0 | change_capacity(new_size); | 293 | 0 | } | 294 | 1.06k | ptrdiff_t increase = new_size - cur_size; | 295 | 1.06k | fill(item_ptr(cur_size), increase); | 296 | 1.06k | _size += increase; | 297 | 1.06k | } |
|
298 | | |
299 | | void reserve(size_type new_capacity) { |
300 | | if (new_capacity > capacity()) { |
301 | | change_capacity(new_capacity); |
302 | | } |
303 | | } |
304 | | |
305 | 32.2M | void shrink_to_fit() { |
306 | 32.2M | change_capacity(size()); |
307 | 32.2M | } |
308 | | |
309 | 48.2M | void clear() { |
310 | 48.2M | resize(0); |
311 | 48.2M | } prevector<28u, unsigned char, unsigned int, int>::clear() Line | Count | Source | 309 | 40.7M | void clear() { | 310 | 40.7M | resize(0); | 311 | 40.7M | } |
prevector<16u, unsigned char, unsigned int, int>::clear() Line | Count | Source | 309 | 7.54M | void clear() { | 310 | 7.54M | resize(0); | 311 | 7.54M | } |
|
312 | | |
313 | 5.50M | iterator insert(iterator pos, const T& value) { |
314 | 5.50M | size_type p = pos - begin(); |
315 | 5.50M | size_type new_size = size() + 1; |
316 | 5.50M | if (capacity() < new_size) { Branch (316:13): [True: 0, False: 5.50M]
|
317 | 0 | change_capacity(new_size + (new_size >> 1)); |
318 | 0 | } |
319 | 5.50M | T* ptr = item_ptr(p); |
320 | 5.50M | T* dst = ptr + 1; |
321 | 5.50M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
322 | 5.50M | _size++; |
323 | 5.50M | new(static_cast<void*>(ptr)) T(value); |
324 | 5.50M | return iterator(ptr); |
325 | 5.50M | } |
326 | | |
327 | | void insert(iterator pos, size_type count, const T& value) { |
328 | | size_type p = pos - begin(); |
329 | | size_type new_size = size() + count; |
330 | | if (capacity() < new_size) { |
331 | | change_capacity(new_size + (new_size >> 1)); |
332 | | } |
333 | | T* ptr = item_ptr(p); |
334 | | T* dst = ptr + count; |
335 | | memmove(dst, ptr, (size() - p) * sizeof(T)); |
336 | | _size += count; |
337 | | fill(item_ptr(p), count, value); |
338 | | } |
339 | | |
340 | | template <std::input_iterator InputIterator> |
341 | 3.46M | void insert(iterator pos, InputIterator first, InputIterator last) { |
342 | 3.46M | size_type p = pos - begin(); |
343 | 3.46M | difference_type count = last - first; |
344 | 3.46M | size_type new_size = size() + count; |
345 | 3.46M | if (capacity() < new_size) { Branch (345:13): [True: 0, False: 56]
Branch (345:13): [True: 355k, False: 3.07M]
Branch (345:13): [True: 0, False: 0]
Branch (345:13): [True: 0, False: 0]
Branch (345:13): [True: 0, False: 0]
Branch (345:13): [True: 0, False: 0]
Branch (345:13): [True: 839, False: 36.2k]
|
346 | 356k | change_capacity(new_size + (new_size >> 1)); |
347 | 356k | } |
348 | 3.46M | T* ptr = item_ptr(p); |
349 | 3.46M | T* dst = ptr + count; |
350 | 3.46M | memmove(dst, ptr, (size() - p) * sizeof(T)); |
351 | 3.46M | _size += count; |
352 | 3.46M | fill(ptr, first, last); |
353 | 3.46M | } _ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Line | Count | Source | 341 | 56 | void insert(iterator pos, InputIterator first, InputIterator last) { | 342 | 56 | size_type p = pos - begin(); | 343 | 56 | difference_type count = last - first; | 344 | 56 | size_type new_size = size() + count; | 345 | 56 | if (capacity() < new_size) { Branch (345:13): [True: 0, False: 56]
| 346 | 0 | change_capacity(new_size + (new_size >> 1)); | 347 | 0 | } | 348 | 56 | T* ptr = item_ptr(p); | 349 | 56 | T* dst = ptr + count; | 350 | 56 | memmove(dst, ptr, (size() - p) * sizeof(T)); | 351 | 56 | _size += count; | 352 | 56 | fill(ptr, first, last); | 353 | 56 | } |
_ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPKhSt4spanIS4_Lm18446744073709551615EEEEEEvNS0_8iteratorET_SA_ Line | Count | Source | 341 | 3.43M | void insert(iterator pos, InputIterator first, InputIterator last) { | 342 | 3.43M | size_type p = pos - begin(); | 343 | 3.43M | difference_type count = last - first; | 344 | 3.43M | size_type new_size = size() + count; | 345 | 3.43M | if (capacity() < new_size) { Branch (345:13): [True: 355k, False: 3.07M]
| 346 | 355k | change_capacity(new_size + (new_size >> 1)); | 347 | 355k | } | 348 | 3.43M | T* ptr = item_ptr(p); | 349 | 3.43M | T* dst = ptr + count; | 350 | 3.43M | memmove(dst, ptr, (size() - p) * sizeof(T)); | 351 | 3.43M | _size += count; | 352 | 3.43M | fill(ptr, first, last); | 353 | 3.43M | } |
Unexecuted instantiation: _ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEEEvNS0_8iteratorET_SA_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPhEEvNS0_8iteratorET_S4_ Unexecuted instantiation: _ZN9prevectorILj35EhjiE6insertITkSt14input_iteratorPKhEEvNS0_8iteratorET_S5_ Unexecuted instantiation: _ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorNS0_8iteratorEEEvS2_T_S3_ _ZN9prevectorILj28EhjiE6insertITkSt14input_iteratorNS0_14const_iteratorEEEvNS0_8iteratorET_S4_ Line | Count | Source | 341 | 37.1k | void insert(iterator pos, InputIterator first, InputIterator last) { | 342 | 37.1k | size_type p = pos - begin(); | 343 | 37.1k | difference_type count = last - first; | 344 | 37.1k | size_type new_size = size() + count; | 345 | 37.1k | if (capacity() < new_size) { Branch (345:13): [True: 839, False: 36.2k]
| 346 | 839 | change_capacity(new_size + (new_size >> 1)); | 347 | 839 | } | 348 | 37.1k | T* ptr = item_ptr(p); | 349 | 37.1k | T* dst = ptr + count; | 350 | 37.1k | memmove(dst, ptr, (size() - p) * sizeof(T)); | 351 | 37.1k | _size += count; | 352 | 37.1k | fill(ptr, first, last); | 353 | 37.1k | } |
|
354 | | |
355 | 7.53M | inline void resize_uninitialized(size_type new_size) { |
356 | | // resize_uninitialized changes the size of the prevector but does not initialize it. |
357 | | // If size < new_size, the added elements must be initialized explicitly. |
358 | 7.53M | if (capacity() < new_size) { Branch (358:13): [True: 5.16M, False: 2.36M]
|
359 | 5.16M | change_capacity(new_size); |
360 | 5.16M | _size += new_size - size(); |
361 | 5.16M | return; |
362 | 5.16M | } |
363 | 2.36M | if (new_size < size()) { Branch (363:13): [True: 0, False: 2.36M]
|
364 | 0 | erase(item_ptr(new_size), end()); |
365 | 2.36M | } else { |
366 | 2.36M | _size += new_size - size(); |
367 | 2.36M | } |
368 | 2.36M | } |
369 | | |
370 | | iterator erase(iterator pos) { |
371 | | return erase(pos, pos + 1); |
372 | | } |
373 | | |
374 | 7.98M | iterator erase(iterator first, iterator last) { |
375 | | // Erase is not allowed to the change the object's capacity. That means |
376 | | // that when starting with an indirectly allocated prevector with |
377 | | // size and capacity > N, the result may be a still indirectly allocated |
378 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is |
379 | | // necessary to switch to the (more efficient) directly allocated |
380 | | // representation (with capacity N and size <= N). |
381 | 7.98M | iterator p = first; |
382 | 7.98M | char* endp = (char*)&(*end()); |
383 | 7.98M | _size -= last - p; |
384 | 7.98M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); |
385 | 7.98M | return first; |
386 | 7.98M | } prevector<28u, unsigned char, unsigned int, int>::erase(prevector<28u, unsigned char, unsigned int, int>::iterator, prevector<28u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 374 | 439k | iterator erase(iterator first, iterator last) { | 375 | | // Erase is not allowed to the change the object's capacity. That means | 376 | | // that when starting with an indirectly allocated prevector with | 377 | | // size and capacity > N, the result may be a still indirectly allocated | 378 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 379 | | // necessary to switch to the (more efficient) directly allocated | 380 | | // representation (with capacity N and size <= N). | 381 | 439k | iterator p = first; | 382 | 439k | char* endp = (char*)&(*end()); | 383 | 439k | _size -= last - p; | 384 | 439k | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 385 | 439k | return first; | 386 | 439k | } |
prevector<16u, unsigned char, unsigned int, int>::erase(prevector<16u, unsigned char, unsigned int, int>::iterator, prevector<16u, unsigned char, unsigned int, int>::iterator) Line | Count | Source | 374 | 7.54M | iterator erase(iterator first, iterator last) { | 375 | | // Erase is not allowed to the change the object's capacity. That means | 376 | | // that when starting with an indirectly allocated prevector with | 377 | | // size and capacity > N, the result may be a still indirectly allocated | 378 | | // prevector with size <= N and capacity > N. A shrink_to_fit() call is | 379 | | // necessary to switch to the (more efficient) directly allocated | 380 | | // representation (with capacity N and size <= N). | 381 | 7.54M | iterator p = first; | 382 | 7.54M | char* endp = (char*)&(*end()); | 383 | 7.54M | _size -= last - p; | 384 | 7.54M | memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); | 385 | 7.54M | return first; | 386 | 7.54M | } |
Unexecuted instantiation: prevector<33u, unsigned char, unsigned int, int>::erase(prevector<33u, unsigned char, unsigned int, int>::iterator, prevector<33u, unsigned char, unsigned int, int>::iterator) |
387 | | |
388 | | template<typename... Args> |
389 | 177k | void emplace_back(Args&&... args) { |
390 | 177k | size_type new_size = size() + 1; |
391 | 177k | if (capacity() < new_size) { Branch (391:13): [True: 0, False: 177k]
|
392 | 0 | change_capacity(new_size + (new_size >> 1)); |
393 | 0 | } |
394 | 177k | new(item_ptr(size())) T(std::forward<Args>(args)...); |
395 | 177k | _size++; |
396 | 177k | } |
397 | | |
398 | 177k | void push_back(const T& value) { |
399 | 177k | emplace_back(value); |
400 | 177k | } |
401 | | |
402 | | void pop_back() { |
403 | | erase(end() - 1, end()); |
404 | | } |
405 | | |
406 | | T& front() { |
407 | | return *item_ptr(0); |
408 | | } |
409 | | |
410 | | const T& front() const { |
411 | | return *item_ptr(0); |
412 | | } |
413 | | |
414 | | T& back() { |
415 | | return *item_ptr(size() - 1); |
416 | | } |
417 | | |
418 | 193 | const T& back() const { |
419 | 193 | return *item_ptr(size() - 1); |
420 | 193 | } |
421 | | |
422 | | void swap(prevector<N, T, Size, Diff>& other) noexcept |
423 | | { |
424 | | std::swap(_union, other._union); |
425 | | std::swap(_size, other._size); |
426 | | } |
427 | | |
428 | 123M | ~prevector() { |
429 | 123M | if (!is_direct()) { Branch (429:13): [True: 33, False: 68.2M]
Branch (429:13): [True: 12.9M, False: 40.4M]
Branch (429:13): [True: 0, False: 2.26M]
Branch (429:13): [True: 0, False: 0]
|
430 | 12.9M | free(_union.indirect_contents.indirect); |
431 | 12.9M | _union.indirect_contents.indirect = nullptr; |
432 | 12.9M | } |
433 | 123M | } prevector<16u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 428 | 68.2M | ~prevector() { | 429 | 68.2M | if (!is_direct()) { Branch (429:13): [True: 33, False: 68.2M]
| 430 | 33 | free(_union.indirect_contents.indirect); | 431 | 33 | _union.indirect_contents.indirect = nullptr; | 432 | 33 | } | 433 | 68.2M | } |
prevector<28u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 428 | 53.3M | ~prevector() { | 429 | 53.3M | if (!is_direct()) { Branch (429:13): [True: 12.9M, False: 40.4M]
| 430 | 12.9M | free(_union.indirect_contents.indirect); | 431 | 12.9M | _union.indirect_contents.indirect = nullptr; | 432 | 12.9M | } | 433 | 53.3M | } |
prevector<33u, unsigned char, unsigned int, int>::~prevector() Line | Count | Source | 428 | 2.26M | ~prevector() { | 429 | 2.26M | if (!is_direct()) { Branch (429:13): [True: 0, False: 2.26M]
| 430 | 0 | free(_union.indirect_contents.indirect); | 431 | 0 | _union.indirect_contents.indirect = nullptr; | 432 | 0 | } | 433 | 2.26M | } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::~prevector() |
434 | | |
435 | 178k | bool operator==(const prevector<N, T, Size, Diff>& other) const { |
436 | 178k | if (other.size() != size()) { Branch (436:13): [True: 170, False: 60.9k]
Branch (436:13): [True: 0, False: 117k]
|
437 | 170 | return false; |
438 | 170 | } |
439 | 178k | const_iterator b1 = begin(); |
440 | 178k | const_iterator b2 = other.begin(); |
441 | 178k | const_iterator e1 = end(); |
442 | 2.57M | while (b1 != e1) { Branch (442:16): [True: 1.92M, False: 60.9k]
Branch (442:16): [True: 474k, False: 112k]
|
443 | 2.40M | if ((*b1) != (*b2)) { Branch (443:17): [True: 0, False: 1.92M]
Branch (443:17): [True: 5.25k, False: 469k]
|
444 | 5.25k | return false; |
445 | 5.25k | } |
446 | 2.39M | ++b1; |
447 | 2.39M | ++b2; |
448 | 2.39M | } |
449 | 173k | return true; |
450 | 178k | } prevector<28u, unsigned char, unsigned int, int>::operator==(prevector<28u, unsigned char, unsigned int, int> const&) const Line | Count | Source | 435 | 61.1k | bool operator==(const prevector<N, T, Size, Diff>& other) const { | 436 | 61.1k | if (other.size() != size()) { Branch (436:13): [True: 170, False: 60.9k]
| 437 | 170 | return false; | 438 | 170 | } | 439 | 60.9k | const_iterator b1 = begin(); | 440 | 60.9k | const_iterator b2 = other.begin(); | 441 | 60.9k | const_iterator e1 = end(); | 442 | 1.98M | while (b1 != e1) { Branch (442:16): [True: 1.92M, False: 60.9k]
| 443 | 1.92M | if ((*b1) != (*b2)) { Branch (443:17): [True: 0, False: 1.92M]
| 444 | 0 | return false; | 445 | 0 | } | 446 | 1.92M | ++b1; | 447 | 1.92M | ++b2; | 448 | 1.92M | } | 449 | 60.9k | return true; | 450 | 60.9k | } |
prevector<16u, unsigned char, unsigned int, int>::operator==(prevector<16u, unsigned char, unsigned int, int> const&) const Line | Count | Source | 435 | 117k | bool operator==(const prevector<N, T, Size, Diff>& other) const { | 436 | 117k | if (other.size() != size()) { Branch (436:13): [True: 0, False: 117k]
| 437 | 0 | return false; | 438 | 0 | } | 439 | 117k | const_iterator b1 = begin(); | 440 | 117k | const_iterator b2 = other.begin(); | 441 | 117k | const_iterator e1 = end(); | 442 | 587k | while (b1 != e1) { Branch (442:16): [True: 474k, False: 112k]
| 443 | 474k | if ((*b1) != (*b2)) { Branch (443:17): [True: 5.25k, False: 469k]
| 444 | 5.25k | return false; | 445 | 5.25k | } | 446 | 469k | ++b1; | 447 | 469k | ++b2; | 448 | 469k | } | 449 | 112k | return true; | 450 | 117k | } |
|
451 | | |
452 | 170 | bool operator!=(const prevector<N, T, Size, Diff>& other) const { |
453 | 170 | return !(*this == other); |
454 | 170 | } |
455 | | |
456 | 7.99M | bool operator<(const prevector<N, T, Size, Diff>& other) const { |
457 | 7.99M | if (size() < other.size()) { Branch (457:13): [True: 0, False: 7.99M]
Branch (457:13): [True: 0, False: 0]
|
458 | 0 | return true; |
459 | 0 | } |
460 | 7.99M | if (size() > other.size()) { Branch (460:13): [True: 0, False: 7.99M]
Branch (460:13): [True: 0, False: 0]
|
461 | 0 | return false; |
462 | 0 | } |
463 | 7.99M | const_iterator b1 = begin(); |
464 | 7.99M | const_iterator b2 = other.begin(); |
465 | 7.99M | const_iterator e1 = end(); |
466 | 26.0M | while (b1 != e1) { Branch (466:16): [True: 26.0M, False: 0]
Branch (466:16): [True: 0, False: 0]
|
467 | 26.0M | if ((*b1) < (*b2)) { Branch (467:17): [True: 4.90M, False: 21.1M]
Branch (467:17): [True: 0, False: 0]
|
468 | 4.90M | return true; |
469 | 4.90M | } |
470 | 21.1M | if ((*b2) < (*b1)) { Branch (470:17): [True: 3.08M, False: 18.0M]
Branch (470:17): [True: 0, False: 0]
|
471 | 3.08M | return false; |
472 | 3.08M | } |
473 | 18.0M | ++b1; |
474 | 18.0M | ++b2; |
475 | 18.0M | } |
476 | 0 | return false; |
477 | 7.99M | } prevector<28u, unsigned char, unsigned int, int>::operator<(prevector<28u, unsigned char, unsigned int, int> const&) const Line | Count | Source | 456 | 7.99M | bool operator<(const prevector<N, T, Size, Diff>& other) const { | 457 | 7.99M | if (size() < other.size()) { Branch (457:13): [True: 0, False: 7.99M]
| 458 | 0 | return true; | 459 | 0 | } | 460 | 7.99M | if (size() > other.size()) { Branch (460:13): [True: 0, False: 7.99M]
| 461 | 0 | return false; | 462 | 0 | } | 463 | 7.99M | const_iterator b1 = begin(); | 464 | 7.99M | const_iterator b2 = other.begin(); | 465 | 7.99M | const_iterator e1 = end(); | 466 | 26.0M | while (b1 != e1) { Branch (466:16): [True: 26.0M, False: 0]
| 467 | 26.0M | if ((*b1) < (*b2)) { Branch (467:17): [True: 4.90M, False: 21.1M]
| 468 | 4.90M | return true; | 469 | 4.90M | } | 470 | 21.1M | if ((*b2) < (*b1)) { Branch (470:17): [True: 3.08M, False: 18.0M]
| 471 | 3.08M | return false; | 472 | 3.08M | } | 473 | 18.0M | ++b1; | 474 | 18.0M | ++b2; | 475 | 18.0M | } | 476 | 0 | return false; | 477 | 7.99M | } |
Unexecuted instantiation: prevector<16u, unsigned char, unsigned int, int>::operator<(prevector<16u, unsigned char, unsigned int, int> const&) const |
478 | | |
479 | 9.15M | size_t allocated_memory() const { |
480 | 9.15M | if (is_direct()) { Branch (480:13): [True: 824k, False: 8.32M]
|
481 | 824k | return 0; |
482 | 8.32M | } else { |
483 | 8.32M | return ((size_t)(sizeof(T))) * _union.indirect_contents.capacity; |
484 | 8.32M | } |
485 | 9.15M | } |
486 | | |
487 | 134k | value_type* data() { |
488 | 134k | return item_ptr(0); |
489 | 134k | } prevector<16u, unsigned char, unsigned int, int>::data() Line | Count | Source | 487 | 260 | value_type* data() { | 488 | 260 | return item_ptr(0); | 489 | 260 | } |
prevector<33u, unsigned char, unsigned int, int>::data() Line | Count | Source | 487 | 1.42k | value_type* data() { | 488 | 1.42k | return item_ptr(0); | 489 | 1.42k | } |
prevector<28u, unsigned char, unsigned int, int>::data() Line | Count | Source | 487 | 132k | value_type* data() { | 488 | 132k | return item_ptr(0); | 489 | 132k | } |
Unexecuted instantiation: prevector<35u, unsigned char, unsigned int, int>::data() |
490 | | |
491 | 80.1M | const value_type* data() const { |
492 | 80.1M | return item_ptr(0); |
493 | 80.1M | } prevector<16u, unsigned char, unsigned int, int>::data() const Line | Count | Source | 491 | 16.0M | const value_type* data() const { | 492 | 16.0M | return item_ptr(0); | 493 | 16.0M | } |
prevector<28u, unsigned char, unsigned int, int>::data() const Line | Count | Source | 491 | 64.0M | const value_type* data() const { | 492 | 64.0M | return item_ptr(0); | 493 | 64.0M | } |
prevector<33u, unsigned char, unsigned int, int>::data() const Line | Count | Source | 491 | 353 | const value_type* data() const { | 492 | 353 | return item_ptr(0); | 493 | 353 | } |
|
494 | | }; |
495 | | |
496 | | #endif // BITCOIN_PREVECTOR_H |