Skip to content

Commit f5cb739

Browse files
committed
Add Span conversion to LocalVector.
1 parent 30bb49e commit f5cb739

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

core/templates/local_vector.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ class LocalVector {
4848
T *data = nullptr;
4949

5050
public:
51-
T *ptr() {
52-
return data;
53-
}
51+
_FORCE_INLINE_ T *ptr() { return data; }
52+
_FORCE_INLINE_ const T *ptr() const { return data; }
53+
_FORCE_INLINE_ U size() const { return count; }
5454

55-
const T *ptr() const {
56-
return data;
57-
}
55+
_FORCE_INLINE_ Span<T> span() const { return Span(data, count); }
56+
_FORCE_INLINE_ operator Span<T>() const { return span(); }
5857

5958
// Must take a copy instead of a reference (see GH-31736).
6059
_FORCE_INLINE_ void push_back(T p_elem) {
@@ -146,7 +145,6 @@ class LocalVector {
146145
}
147146
}
148147

149-
_FORCE_INLINE_ U size() const { return count; }
150148
void resize(U p_size) {
151149
if (p_size < count) {
152150
if constexpr (!std::is_trivially_destructible_v<T> && !force_trivial) {

0 commit comments

Comments
 (0)