Line | Count | Source |
1 | | // Copyright 2018 The RE2 Authors. All Rights Reserved. |
2 | | // Use of this source code is governed by a BSD-style |
3 | | // license that can be found in the LICENSE file. |
4 | | |
5 | | #ifndef RE2_POD_ARRAY_H_ |
6 | | #define RE2_POD_ARRAY_H_ |
7 | | |
8 | | #include <memory> |
9 | | #include <type_traits> |
10 | | |
11 | | namespace re2 { |
12 | | |
13 | | template <typename T> |
14 | | class PODArray { |
15 | | public: |
16 | | static_assert(std::is_trivial<T>::value && std::is_standard_layout<T>::value, |
17 | | "T must be POD"); |
18 | | |
19 | | PODArray() |
20 | 271k | : ptr_() {} re2::PODArray<re2::Regexp*>::PODArray() Line | Count | Source | 20 | 123k | : ptr_() {} |
Unexecuted instantiation: re2::PODArray<unsigned long>::PODArray() Unexecuted instantiation: re2::PODArray<char const*>::PODArray() Unexecuted instantiation: re2::PODArray<re2::Job>::PODArray() re2::PODArray<re2::Prog::Inst>::PODArray() Line | Count | Source | 20 | 57.7k | : ptr_() {} |
re2::PODArray<int>::PODArray() Line | Count | Source | 20 | 28.9k | : ptr_() {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray() Line | Count | Source | 20 | 2.77k | : ptr_() {} |
re2::PODArray<re2::NFA::AddState>::PODArray() Line | Count | Source | 20 | 1.38k | : ptr_() {} |
re2::PODArray<unsigned short>::PODArray() Line | Count | Source | 20 | 28.8k | : ptr_() {} |
re2::PODArray<unsigned char>::PODArray() Line | Count | Source | 20 | 28.8k | : ptr_() {} |
|
21 | | explicit PODArray(int len) |
22 | 1.19M | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} re2::PODArray<int>::PODArray(int) Line | Count | Source | 22 | 750k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::SparseArray<int>::IndexValue>::PODArray(int) Line | Count | Source | 22 | 86.4k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::Regexp*>::PODArray(int) Line | Count | Source | 22 | 112k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
Unexecuted instantiation: re2::PODArray<re2::Job>::PODArray(int) Unexecuted instantiation: re2::PODArray<unsigned long>::PODArray(int) Unexecuted instantiation: re2::PODArray<char const*>::PODArray(int) re2::PODArray<re2::Prog::Inst>::PODArray(int) Line | Count | Source | 22 | 178k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray(int) Line | Count | Source | 22 | 2.77k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::NFA::AddState>::PODArray(int) Line | Count | Source | 22 | 1.38k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::InstCond>::PODArray(int) Line | Count | Source | 22 | 27.1k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<unsigned char>::PODArray(int) Line | Count | Source | 22 | 16.1k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<unsigned short>::PODArray(int) Line | Count | Source | 22 | 24.6k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
|
23 | | |
24 | 5.00G | T* data() const { |
25 | 5.00G | return ptr_.get(); |
26 | 5.00G | } re2::PODArray<re2::SparseArray<int>::IndexValue>::data() const Line | Count | Source | 24 | 1.47G | T* data() const { | 25 | 1.47G | return ptr_.get(); | 26 | 1.47G | } |
re2::PODArray<unsigned short>::data() const Line | Count | Source | 24 | 81.6k | T* data() const { | 25 | 81.6k | return ptr_.get(); | 26 | 81.6k | } |
re2::PODArray<re2::Prog::Inst>::data() const Line | Count | Source | 24 | 145M | T* data() const { | 25 | 145M | return ptr_.get(); | 26 | 145M | } |
re2::PODArray<re2::Regexp*>::data() const Line | Count | Source | 24 | 130k | T* data() const { | 25 | 130k | return ptr_.get(); | 26 | 130k | } |
Unexecuted instantiation: re2::PODArray<re2::Job>::data() const Unexecuted instantiation: re2::PODArray<unsigned long>::data() const Unexecuted instantiation: re2::PODArray<char const*>::data() const re2::PODArray<int>::data() const Line | Count | Source | 24 | 3.01G | T* data() const { | 25 | 3.01G | return ptr_.get(); | 26 | 3.01G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::data() const Line | Count | Source | 24 | 358M | T* data() const { | 25 | 358M | return ptr_.get(); | 26 | 358M | } |
re2::PODArray<re2::NFA::AddState>::data() const Line | Count | Source | 24 | 12.8M | T* data() const { | 25 | 12.8M | return ptr_.get(); | 26 | 12.8M | } |
re2::PODArray<unsigned char>::data() const Line | Count | Source | 24 | 18.3k | T* data() const { | 25 | 18.3k | return ptr_.get(); | 26 | 18.3k | } |
|
27 | | |
28 | 3.75G | int size() const { |
29 | 3.75G | return ptr_.get_deleter().len_; |
30 | 3.75G | } Unexecuted instantiation: re2::PODArray<re2::Job>::size() const Unexecuted instantiation: re2::PODArray<char const*>::size() const re2::PODArray<re2::Prog::Inst>::size() const Line | Count | Source | 28 | 181M | int size() const { | 29 | 181M | return ptr_.get_deleter().len_; | 30 | 181M | } |
re2::PODArray<int>::size() const Line | Count | Source | 28 | 2.07G | int size() const { | 29 | 2.07G | return ptr_.get_deleter().len_; | 30 | 2.07G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::size() const Line | Count | Source | 28 | 198M | int size() const { | 29 | 198M | return ptr_.get_deleter().len_; | 30 | 198M | } |
re2::PODArray<re2::SparseArray<int>::IndexValue>::size() const Line | Count | Source | 28 | 1.29G | int size() const { | 29 | 1.29G | return ptr_.get_deleter().len_; | 30 | 1.29G | } |
|
31 | | |
32 | 12.2G | T& operator[](int pos) const { |
33 | 12.2G | return ptr_[pos]; |
34 | 12.2G | } re2::PODArray<re2::Prog::Inst>::operator[](int) const Line | Count | Source | 32 | 2.58G | T& operator[](int pos) const { | 33 | 2.58G | return ptr_[pos]; | 34 | 2.58G | } |
Unexecuted instantiation: re2::PODArray<unsigned long>::operator[](int) const Unexecuted instantiation: re2::PODArray<re2::Job>::operator[](int) const Unexecuted instantiation: re2::PODArray<char const*>::operator[](int) const re2::PODArray<re2::Regexp*>::operator[](int) const Line | Count | Source | 32 | 2.62M | T& operator[](int pos) const { | 33 | 2.62M | return ptr_[pos]; | 34 | 2.62M | } |
re2::PODArray<int>::operator[](int) const Line | Count | Source | 32 | 7.79G | T& operator[](int pos) const { | 33 | 7.79G | return ptr_[pos]; | 34 | 7.79G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::operator[](int) const Line | Count | Source | 32 | 308M | T& operator[](int pos) const { | 33 | 308M | return ptr_[pos]; | 34 | 308M | } |
re2::PODArray<re2::SparseArray<int>::IndexValue>::operator[](int) const Line | Count | Source | 32 | 1.53G | T& operator[](int pos) const { | 33 | 1.53G | return ptr_[pos]; | 34 | 1.53G | } |
re2::PODArray<re2::InstCond>::operator[](int) const Line | Count | Source | 32 | 26.8M | T& operator[](int pos) const { | 33 | 26.8M | return ptr_[pos]; | 34 | 26.8M | } |
re2::PODArray<unsigned short>::operator[](int) const Line | Count | Source | 32 | 1.06M | T& operator[](int pos) const { | 33 | 1.06M | return ptr_[pos]; | 34 | 1.06M | } |
|
35 | | |
36 | | private: |
37 | | struct Deleter { |
38 | | Deleter() |
39 | 271k | : len_(0) {} re2::PODArray<re2::Regexp*>::Deleter::Deleter() Line | Count | Source | 39 | 123k | : len_(0) {} |
Unexecuted instantiation: re2::PODArray<unsigned long>::Deleter::Deleter() Unexecuted instantiation: re2::PODArray<char const*>::Deleter::Deleter() Unexecuted instantiation: re2::PODArray<re2::Job>::Deleter::Deleter() re2::PODArray<re2::Prog::Inst>::Deleter::Deleter() Line | Count | Source | 39 | 57.7k | : len_(0) {} |
re2::PODArray<int>::Deleter::Deleter() Line | Count | Source | 39 | 28.9k | : len_(0) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter() Line | Count | Source | 39 | 2.77k | : len_(0) {} |
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter() Line | Count | Source | 39 | 1.38k | : len_(0) {} |
re2::PODArray<unsigned short>::Deleter::Deleter() Line | Count | Source | 39 | 28.8k | : len_(0) {} |
re2::PODArray<unsigned char>::Deleter::Deleter() Line | Count | Source | 39 | 28.8k | : len_(0) {} |
|
40 | | explicit Deleter(int len) |
41 | 1.19M | : len_(len) {} re2::PODArray<int>::Deleter::Deleter(int) Line | Count | Source | 41 | 750k | : len_(len) {} |
re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::Deleter(int) Line | Count | Source | 41 | 86.4k | : len_(len) {} |
re2::PODArray<re2::Regexp*>::Deleter::Deleter(int) Line | Count | Source | 41 | 112k | : len_(len) {} |
Unexecuted instantiation: re2::PODArray<re2::Job>::Deleter::Deleter(int) Unexecuted instantiation: re2::PODArray<unsigned long>::Deleter::Deleter(int) Unexecuted instantiation: re2::PODArray<char const*>::Deleter::Deleter(int) re2::PODArray<re2::Prog::Inst>::Deleter::Deleter(int) Line | Count | Source | 41 | 178k | : len_(len) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter(int) Line | Count | Source | 41 | 2.77k | : len_(len) {} |
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter(int) Line | Count | Source | 41 | 1.38k | : len_(len) {} |
re2::PODArray<re2::InstCond>::Deleter::Deleter(int) Line | Count | Source | 41 | 27.1k | : len_(len) {} |
re2::PODArray<unsigned char>::Deleter::Deleter(int) Line | Count | Source | 41 | 16.1k | : len_(len) {} |
re2::PODArray<unsigned short>::Deleter::Deleter(int) Line | Count | Source | 41 | 24.6k | : len_(len) {} |
|
42 | | |
43 | 1.19M | void operator()(T* ptr) const { |
44 | 1.19M | std::allocator<T>().deallocate(ptr, len_); |
45 | 1.19M | } re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::operator()(re2::SparseArray<int>::IndexValue*) const Line | Count | Source | 43 | 86.4k | void operator()(T* ptr) const { | 44 | 86.4k | std::allocator<T>().deallocate(ptr, len_); | 45 | 86.4k | } |
re2::PODArray<int>::Deleter::operator()(int*) const Line | Count | Source | 43 | 750k | void operator()(T* ptr) const { | 44 | 750k | std::allocator<T>().deallocate(ptr, len_); | 45 | 750k | } |
re2::PODArray<re2::Regexp*>::Deleter::operator()(re2::Regexp**) const Line | Count | Source | 43 | 112k | void operator()(T* ptr) const { | 44 | 112k | std::allocator<T>().deallocate(ptr, len_); | 45 | 112k | } |
Unexecuted instantiation: re2::PODArray<char const*>::Deleter::operator()(char const**) const Unexecuted instantiation: re2::PODArray<unsigned long>::Deleter::operator()(unsigned long*) const Unexecuted instantiation: re2::PODArray<re2::Job>::Deleter::operator()(re2::Job*) const re2::PODArray<re2::Prog::Inst>::Deleter::operator()(re2::Prog::Inst*) const Line | Count | Source | 43 | 178k | void operator()(T* ptr) const { | 44 | 178k | std::allocator<T>().deallocate(ptr, len_); | 45 | 178k | } |
re2::PODArray<re2::NFA::AddState>::Deleter::operator()(re2::NFA::AddState*) const Line | Count | Source | 43 | 1.38k | void operator()(T* ptr) const { | 44 | 1.38k | std::allocator<T>().deallocate(ptr, len_); | 45 | 1.38k | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::operator()(re2::SparseArray<re2::NFA::Thread*>::IndexValue*) const Line | Count | Source | 43 | 2.77k | void operator()(T* ptr) const { | 44 | 2.77k | std::allocator<T>().deallocate(ptr, len_); | 45 | 2.77k | } |
re2::PODArray<unsigned char>::Deleter::operator()(unsigned char*) const Line | Count | Source | 43 | 16.1k | void operator()(T* ptr) const { | 44 | 16.1k | std::allocator<T>().deallocate(ptr, len_); | 45 | 16.1k | } |
re2::PODArray<re2::InstCond>::Deleter::operator()(re2::InstCond*) const Line | Count | Source | 43 | 27.1k | void operator()(T* ptr) const { | 44 | 27.1k | std::allocator<T>().deallocate(ptr, len_); | 45 | 27.1k | } |
re2::PODArray<unsigned short>::Deleter::operator()(unsigned short*) const Line | Count | Source | 43 | 24.6k | void operator()(T* ptr) const { | 44 | 24.6k | std::allocator<T>().deallocate(ptr, len_); | 45 | 24.6k | } |
|
46 | | |
47 | | int len_; |
48 | | }; |
49 | | |
50 | | std::unique_ptr<T[], Deleter> ptr_; |
51 | | }; |
52 | | |
53 | | } // namespace re2 |
54 | | |
55 | | #endif // RE2_POD_ARRAY_H_ |