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 | 395k | : ptr_() {} re2::PODArray<re2::Regexp*>::PODArray() Line | Count | Source | 20 | 181k | : 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 | 83.8k | : ptr_() {} |
re2::PODArray<int>::PODArray() Line | Count | Source | 20 | 41.9k | : ptr_() {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray() Line | Count | Source | 20 | 3.33k | : ptr_() {} |
re2::PODArray<re2::NFA::AddState>::PODArray() Line | Count | Source | 20 | 1.66k | : ptr_() {} |
re2::PODArray<unsigned short>::PODArray() Line | Count | Source | 20 | 41.9k | : ptr_() {} |
re2::PODArray<unsigned char>::PODArray() Line | Count | Source | 20 | 41.9k | : ptr_() {} |
|
21 | | explicit PODArray(int len) |
22 | 1.77M | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} re2::PODArray<int>::PODArray(int) Line | Count | Source | 22 | 1.11M | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::SparseArray<int>::IndexValue>::PODArray(int) Line | Count | Source | 22 | 125k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::Regexp*>::PODArray(int) Line | Count | Source | 22 | 167k | : 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 | 262k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray(int) Line | Count | Source | 22 | 3.33k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::NFA::AddState>::PODArray(int) Line | Count | Source | 22 | 1.66k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<re2::InstCond>::PODArray(int) Line | Count | Source | 22 | 39.6k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<unsigned char>::PODArray(int) Line | Count | Source | 22 | 23.9k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
re2::PODArray<unsigned short>::PODArray(int) Line | Count | Source | 22 | 35.7k | : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {} |
|
23 | | |
24 | 5.49G | T* data() const { |
25 | 5.49G | return ptr_.get(); |
26 | 5.49G | } re2::PODArray<re2::SparseArray<int>::IndexValue>::data() const Line | Count | Source | 24 | 1.29G | T* data() const { | 25 | 1.29G | return ptr_.get(); | 26 | 1.29G | } |
re2::PODArray<unsigned short>::data() const Line | Count | Source | 24 | 118k | T* data() const { | 25 | 118k | return ptr_.get(); | 26 | 118k | } |
re2::PODArray<re2::Prog::Inst>::data() const Line | Count | Source | 24 | 117M | T* data() const { | 25 | 117M | return ptr_.get(); | 26 | 117M | } |
re2::PODArray<re2::Regexp*>::data() const Line | Count | Source | 24 | 193k | T* data() const { | 25 | 193k | return ptr_.get(); | 26 | 193k | } |
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 | 2.89G | T* data() const { | 25 | 2.89G | return ptr_.get(); | 26 | 2.89G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::data() const Line | Count | Source | 24 | 1.18G | T* data() const { | 25 | 1.18G | return ptr_.get(); | 26 | 1.18G | } |
re2::PODArray<re2::NFA::AddState>::data() const Line | Count | Source | 24 | 6.34M | T* data() const { | 25 | 6.34M | return ptr_.get(); | 26 | 6.34M | } |
re2::PODArray<unsigned char>::data() const Line | Count | Source | 24 | 26.6k | T* data() const { | 25 | 26.6k | return ptr_.get(); | 26 | 26.6k | } |
|
27 | | |
28 | 3.84G | int size() const { |
29 | 3.84G | return ptr_.get_deleter().len_; |
30 | 3.84G | } 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 | 138M | int size() const { | 29 | 138M | return ptr_.get_deleter().len_; | 30 | 138M | } |
re2::PODArray<int>::size() const Line | Count | Source | 28 | 1.91G | int size() const { | 29 | 1.91G | return ptr_.get_deleter().len_; | 30 | 1.91G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::size() const Line | Count | Source | 28 | 697M | int size() const { | 29 | 697M | return ptr_.get_deleter().len_; | 30 | 697M | } |
re2::PODArray<re2::SparseArray<int>::IndexValue>::size() const Line | Count | Source | 28 | 1.09G | int size() const { | 29 | 1.09G | return ptr_.get_deleter().len_; | 30 | 1.09G | } |
|
31 | | |
32 | 12.6G | T& operator[](int pos) const { |
33 | 12.6G | return ptr_[pos]; |
34 | 12.6G | } re2::PODArray<re2::Prog::Inst>::operator[](int) const Line | Count | Source | 32 | 2.01G | T& operator[](int pos) const { | 33 | 2.01G | return ptr_[pos]; | 34 | 2.01G | } |
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 | 3.61M | T& operator[](int pos) const { | 33 | 3.61M | return ptr_[pos]; | 34 | 3.61M | } |
re2::PODArray<int>::operator[](int) const Line | Count | Source | 32 | 8.22G | T& operator[](int pos) const { | 33 | 8.22G | return ptr_[pos]; | 34 | 8.22G | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::operator[](int) const Line | Count | Source | 32 | 971M | T& operator[](int pos) const { | 33 | 971M | return ptr_[pos]; | 34 | 971M | } |
re2::PODArray<re2::SparseArray<int>::IndexValue>::operator[](int) const Line | Count | Source | 32 | 1.33G | T& operator[](int pos) const { | 33 | 1.33G | return ptr_[pos]; | 34 | 1.33G | } |
re2::PODArray<re2::InstCond>::operator[](int) const Line | Count | Source | 32 | 41.0M | T& operator[](int pos) const { | 33 | 41.0M | return ptr_[pos]; | 34 | 41.0M | } |
re2::PODArray<unsigned short>::operator[](int) const Line | Count | Source | 32 | 1.64M | T& operator[](int pos) const { | 33 | 1.64M | return ptr_[pos]; | 34 | 1.64M | } |
|
35 | | |
36 | | private: |
37 | | struct Deleter { |
38 | | Deleter() |
39 | 395k | : len_(0) {} re2::PODArray<re2::Regexp*>::Deleter::Deleter() Line | Count | Source | 39 | 181k | : 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 | 83.8k | : len_(0) {} |
re2::PODArray<int>::Deleter::Deleter() Line | Count | Source | 39 | 41.9k | : len_(0) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter() Line | Count | Source | 39 | 3.33k | : len_(0) {} |
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter() Line | Count | Source | 39 | 1.66k | : len_(0) {} |
re2::PODArray<unsigned short>::Deleter::Deleter() Line | Count | Source | 39 | 41.9k | : len_(0) {} |
re2::PODArray<unsigned char>::Deleter::Deleter() Line | Count | Source | 39 | 41.9k | : len_(0) {} |
|
40 | | explicit Deleter(int len) |
41 | 1.77M | : len_(len) {} re2::PODArray<int>::Deleter::Deleter(int) Line | Count | Source | 41 | 1.11M | : len_(len) {} |
re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::Deleter(int) Line | Count | Source | 41 | 125k | : len_(len) {} |
re2::PODArray<re2::Regexp*>::Deleter::Deleter(int) Line | Count | Source | 41 | 167k | : 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 | 262k | : len_(len) {} |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter(int) Line | Count | Source | 41 | 3.33k | : len_(len) {} |
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter(int) Line | Count | Source | 41 | 1.66k | : len_(len) {} |
re2::PODArray<re2::InstCond>::Deleter::Deleter(int) Line | Count | Source | 41 | 39.6k | : len_(len) {} |
re2::PODArray<unsigned char>::Deleter::Deleter(int) Line | Count | Source | 41 | 23.9k | : len_(len) {} |
re2::PODArray<unsigned short>::Deleter::Deleter(int) Line | Count | Source | 41 | 35.7k | : len_(len) {} |
|
42 | | |
43 | 1.77M | void operator()(T* ptr) const { |
44 | 1.77M | std::allocator<T>().deallocate(ptr, len_); |
45 | 1.77M | } re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::operator()(re2::SparseArray<int>::IndexValue*) const Line | Count | Source | 43 | 125k | void operator()(T* ptr) const { | 44 | 125k | std::allocator<T>().deallocate(ptr, len_); | 45 | 125k | } |
re2::PODArray<int>::Deleter::operator()(int*) const Line | Count | Source | 43 | 1.11M | void operator()(T* ptr) const { | 44 | 1.11M | std::allocator<T>().deallocate(ptr, len_); | 45 | 1.11M | } |
re2::PODArray<re2::Regexp*>::Deleter::operator()(re2::Regexp**) const Line | Count | Source | 43 | 167k | void operator()(T* ptr) const { | 44 | 167k | std::allocator<T>().deallocate(ptr, len_); | 45 | 167k | } |
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 | 262k | void operator()(T* ptr) const { | 44 | 262k | std::allocator<T>().deallocate(ptr, len_); | 45 | 262k | } |
re2::PODArray<re2::NFA::AddState>::Deleter::operator()(re2::NFA::AddState*) const Line | Count | Source | 43 | 1.66k | void operator()(T* ptr) const { | 44 | 1.66k | std::allocator<T>().deallocate(ptr, len_); | 45 | 1.66k | } |
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::operator()(re2::SparseArray<re2::NFA::Thread*>::IndexValue*) const Line | Count | Source | 43 | 3.33k | void operator()(T* ptr) const { | 44 | 3.33k | std::allocator<T>().deallocate(ptr, len_); | 45 | 3.33k | } |
re2::PODArray<unsigned char>::Deleter::operator()(unsigned char*) const Line | Count | Source | 43 | 23.9k | void operator()(T* ptr) const { | 44 | 23.9k | std::allocator<T>().deallocate(ptr, len_); | 45 | 23.9k | } |
re2::PODArray<re2::InstCond>::Deleter::operator()(re2::InstCond*) const Line | Count | Source | 43 | 39.6k | void operator()(T* ptr) const { | 44 | 39.6k | std::allocator<T>().deallocate(ptr, len_); | 45 | 39.6k | } |
re2::PODArray<unsigned short>::Deleter::operator()(unsigned short*) const Line | Count | Source | 43 | 35.7k | void operator()(T* ptr) const { | 44 | 35.7k | std::allocator<T>().deallocate(ptr, len_); | 45 | 35.7k | } |
|
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_ |