Coverage Report

Created: 2024-08-25 12:20

/src/re2/re2/pod_array.h
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
314k
      : ptr_() {}
re2::PODArray<re2::Regexp*>::PODArray()
Line
Count
Source
20
140k
      : 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
67.6k
      : ptr_() {}
re2::PODArray<int>::PODArray()
Line
Count
Source
20
34.0k
      : ptr_() {}
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray()
Line
Count
Source
20
3.30k
      : ptr_() {}
re2::PODArray<re2::NFA::AddState>::PODArray()
Line
Count
Source
20
1.65k
      : ptr_() {}
re2::PODArray<unsigned short>::PODArray()
Line
Count
Source
20
33.8k
      : ptr_() {}
re2::PODArray<unsigned char>::PODArray()
Line
Count
Source
20
33.8k
      : ptr_() {}
21
  explicit PODArray(int len)
22
1.41M
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<int>::PODArray(int)
Line
Count
Source
22
888k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<re2::SparseArray<int>::IndexValue>::PODArray(int)
Line
Count
Source
22
101k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<re2::Regexp*>::PODArray(int)
Line
Count
Source
22
128k
      : 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
208k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::PODArray(int)
Line
Count
Source
22
3.30k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<re2::NFA::AddState>::PODArray(int)
Line
Count
Source
22
1.65k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<re2::InstCond>::PODArray(int)
Line
Count
Source
22
31.9k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<unsigned char>::PODArray(int)
Line
Count
Source
22
19.2k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
re2::PODArray<unsigned short>::PODArray(int)
Line
Count
Source
22
28.9k
      : ptr_(std::allocator<T>().allocate(len), Deleter(len)) {}
23
24
5.37G
  T* data() const {
25
5.37G
    return ptr_.get();
26
5.37G
  }
re2::PODArray<re2::SparseArray<int>::IndexValue>::data() const
Line
Count
Source
24
1.72G
  T* data() const {
25
1.72G
    return ptr_.get();
26
1.72G
  }
re2::PODArray<unsigned short>::data() const
Line
Count
Source
24
95.9k
  T* data() const {
25
95.9k
    return ptr_.get();
26
95.9k
  }
re2::PODArray<re2::Prog::Inst>::data() const
Line
Count
Source
24
137M
  T* data() const {
25
137M
    return ptr_.get();
26
137M
  }
re2::PODArray<re2::Regexp*>::data() const
Line
Count
Source
24
149k
  T* data() const {
25
149k
    return ptr_.get();
26
149k
  }
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.24G
  T* data() const {
25
3.24G
    return ptr_.get();
26
3.24G
  }
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::data() const
Line
Count
Source
24
263M
  T* data() const {
25
263M
    return ptr_.get();
26
263M
  }
re2::PODArray<re2::NFA::AddState>::data() const
Line
Count
Source
24
8.07M
  T* data() const {
25
8.07M
    return ptr_.get();
26
8.07M
  }
re2::PODArray<unsigned char>::data() const
Line
Count
Source
24
21.8k
  T* data() const {
25
21.8k
    return ptr_.get();
26
21.8k
  }
27
28
4.17G
  int size() const {
29
4.17G
    return ptr_.get_deleter().len_;
30
4.17G
  }
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
166M
  int size() const {
29
166M
    return ptr_.get_deleter().len_;
30
166M
  }
re2::PODArray<int>::size() const
Line
Count
Source
28
2.31G
  int size() const {
29
2.31G
    return ptr_.get_deleter().len_;
30
2.31G
  }
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::size() const
Line
Count
Source
28
146M
  int size() const {
29
146M
    return ptr_.get_deleter().len_;
30
146M
  }
re2::PODArray<re2::SparseArray<int>::IndexValue>::size() const
Line
Count
Source
28
1.54G
  int size() const {
29
1.54G
    return ptr_.get_deleter().len_;
30
1.54G
  }
31
32
12.8G
  T& operator[](int pos) const {
33
12.8G
    return ptr_[pos];
34
12.8G
  }
re2::PODArray<re2::Prog::Inst>::operator[](int) const
Line
Count
Source
32
2.21G
  T& operator[](int pos) const {
33
2.21G
    return ptr_[pos];
34
2.21G
  }
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.90M
  T& operator[](int pos) const {
33
2.90M
    return ptr_[pos];
34
2.90M
  }
re2::PODArray<int>::operator[](int) const
Line
Count
Source
32
8.59G
  T& operator[](int pos) const {
33
8.59G
    return ptr_[pos];
34
8.59G
  }
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::operator[](int) const
Line
Count
Source
32
228M
  T& operator[](int pos) const {
33
228M
    return ptr_[pos];
34
228M
  }
re2::PODArray<re2::SparseArray<int>::IndexValue>::operator[](int) const
Line
Count
Source
32
1.75G
  T& operator[](int pos) const {
33
1.75G
    return ptr_[pos];
34
1.75G
  }
re2::PODArray<re2::InstCond>::operator[](int) const
Line
Count
Source
32
35.3M
  T& operator[](int pos) const {
33
35.3M
    return ptr_[pos];
34
35.3M
  }
re2::PODArray<unsigned short>::operator[](int) const
Line
Count
Source
32
1.22M
  T& operator[](int pos) const {
33
1.22M
    return ptr_[pos];
34
1.22M
  }
35
36
 private:
37
  struct Deleter {
38
    Deleter()
39
314k
        : len_(0) {}
re2::PODArray<re2::Regexp*>::Deleter::Deleter()
Line
Count
Source
39
140k
        : 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
67.6k
        : len_(0) {}
re2::PODArray<int>::Deleter::Deleter()
Line
Count
Source
39
34.0k
        : len_(0) {}
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter()
Line
Count
Source
39
3.30k
        : len_(0) {}
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter()
Line
Count
Source
39
1.65k
        : len_(0) {}
re2::PODArray<unsigned short>::Deleter::Deleter()
Line
Count
Source
39
33.8k
        : len_(0) {}
re2::PODArray<unsigned char>::Deleter::Deleter()
Line
Count
Source
39
33.8k
        : len_(0) {}
40
    explicit Deleter(int len)
41
1.41M
        : len_(len) {}
re2::PODArray<int>::Deleter::Deleter(int)
Line
Count
Source
41
888k
        : len_(len) {}
re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::Deleter(int)
Line
Count
Source
41
101k
        : len_(len) {}
re2::PODArray<re2::Regexp*>::Deleter::Deleter(int)
Line
Count
Source
41
128k
        : 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
208k
        : len_(len) {}
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::Deleter(int)
Line
Count
Source
41
3.30k
        : len_(len) {}
re2::PODArray<re2::NFA::AddState>::Deleter::Deleter(int)
Line
Count
Source
41
1.65k
        : len_(len) {}
re2::PODArray<re2::InstCond>::Deleter::Deleter(int)
Line
Count
Source
41
31.9k
        : len_(len) {}
re2::PODArray<unsigned char>::Deleter::Deleter(int)
Line
Count
Source
41
19.2k
        : len_(len) {}
re2::PODArray<unsigned short>::Deleter::Deleter(int)
Line
Count
Source
41
28.9k
        : len_(len) {}
42
43
1.41M
    void operator()(T* ptr) const {
44
1.41M
      std::allocator<T>().deallocate(ptr, len_);
45
1.41M
    }
re2::PODArray<re2::SparseArray<int>::IndexValue>::Deleter::operator()(re2::SparseArray<int>::IndexValue*) const
Line
Count
Source
43
101k
    void operator()(T* ptr) const {
44
101k
      std::allocator<T>().deallocate(ptr, len_);
45
101k
    }
re2::PODArray<int>::Deleter::operator()(int*) const
Line
Count
Source
43
888k
    void operator()(T* ptr) const {
44
888k
      std::allocator<T>().deallocate(ptr, len_);
45
888k
    }
re2::PODArray<re2::Regexp*>::Deleter::operator()(re2::Regexp**) const
Line
Count
Source
43
128k
    void operator()(T* ptr) const {
44
128k
      std::allocator<T>().deallocate(ptr, len_);
45
128k
    }
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
208k
    void operator()(T* ptr) const {
44
208k
      std::allocator<T>().deallocate(ptr, len_);
45
208k
    }
re2::PODArray<re2::NFA::AddState>::Deleter::operator()(re2::NFA::AddState*) const
Line
Count
Source
43
1.65k
    void operator()(T* ptr) const {
44
1.65k
      std::allocator<T>().deallocate(ptr, len_);
45
1.65k
    }
re2::PODArray<re2::SparseArray<re2::NFA::Thread*>::IndexValue>::Deleter::operator()(re2::SparseArray<re2::NFA::Thread*>::IndexValue*) const
Line
Count
Source
43
3.30k
    void operator()(T* ptr) const {
44
3.30k
      std::allocator<T>().deallocate(ptr, len_);
45
3.30k
    }
re2::PODArray<unsigned char>::Deleter::operator()(unsigned char*) const
Line
Count
Source
43
19.2k
    void operator()(T* ptr) const {
44
19.2k
      std::allocator<T>().deallocate(ptr, len_);
45
19.2k
    }
re2::PODArray<re2::InstCond>::Deleter::operator()(re2::InstCond*) const
Line
Count
Source
43
31.9k
    void operator()(T* ptr) const {
44
31.9k
      std::allocator<T>().deallocate(ptr, len_);
45
31.9k
    }
re2::PODArray<unsigned short>::Deleter::operator()(unsigned short*) const
Line
Count
Source
43
28.9k
    void operator()(T* ptr) const {
44
28.9k
      std::allocator<T>().deallocate(ptr, len_);
45
28.9k
    }
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_