Repository: godotengine/godot
File: core/templates/span.h (C/C++)

Code before:
	}

	for (uint64_t i = p_from; i < size(); i++) {
		if (ptr()[i] == p_val) {
			return i;
		}
	}

	return -1;
}

template <typename T>
constexpr int64_t Span<T>::find_seq(const Span<T> &p_span, int64_t p_from) const {
	const int64_t s = size();
	const int64_t p_s = p_span.size();

	if (p_from < 0 || s == 0) {
		return -1;
	}
	if (p_s == 0 || p_s > s){
		return -1;
	}
	if (p_s == 1){
		return find(p_span.ptr()[0], p_from);
	}

	for (int64_t i = p_from; i < s - p_s; i++) {
		bool found = true;
		for (int64_t j = 0; j < p_s; j++){
			if(ptr()[i + j] != p_span.ptr()[j]){
				found = false;
				break;
			}
		}
		if (found){
			return i;
		}
	}

	return -1;
}

template <typename T>
constexpr int64_t Span<T>::rfind(const T &p_val, int64_t p_from) const {
	const int64_t s = size();

	if (p_from < 0) {
		p_from = s + p_from;
	}
	if (p_from < 0 || p_from >= s) {
		p_from = s - 1;

Review comment (suggestion):
As explained, skipping this part:

```suggestion
```


Code after:
	_FORCE_INLINE_ constexpr uint64_t size() const { return _len; }
	_FORCE_INLINE_ constexpr bool is_empty() const { return _len == 0; }

	_FORCE_INLINE_ constexpr const T *ptr() const { return _ptr; }

	// NOTE: Span subscripts sanity check the bounds to avoid undefined behavior.
	//       This is slower than direct buffer access and can prevent autovectorization.
	//       If the bounds are known, use ptr() subscript instead.
	_FORCE_INLINE_ constexpr const T &operator[](uint64_t p_idx) const {
		CRASH_COND(p_idx >= _len);
		return _ptr[p_idx];
	}

	_FORCE_INLINE_ constexpr const T *begin() const { return _ptr; }
	_FORCE_INLINE_ constexpr const T *end() const { return _ptr + _len; }

	template <typename T1>
	_FORCE_INLINE_ constexpr Span<T1> reinterpret() const {
		return Span<T1>(reinterpret_cast<const T1 *>(_ptr), _len * sizeof(T) / sizeof(T1));
	}

	// Algorithms.
	constexpr int64_t find(const T &p_val, uint64_t p_from = 0) const;
	constexpr int64_t find_sequence(const Span<T> &p_span, uint64_t p_from = 0) const;
	constexpr int64_t rfind(const T &p_val, uint64_t p_from) const;
	_FORCE_INLINE_ constexpr int64_t rfind(const T &p_val) const { return rfind(p_val, size() - 1); }
	constexpr int64_t rfind_sequence(const Span<T> &p_span, uint64_t p_from) const;
	_FORCE_INLINE_ constexpr int64_t rfind_sequence(const Span<T> &p_span) const { return rfind_sequence(p_span, size() - p_span.size()); }
	constexpr uint64_t count(const T &p_val) const;
	/// Find the index of the given value using binary search.
	/// Note: Assumes that elements in the span are sorted. Otherwise, use find() instead.
	template <typename Comparator = Comparator<T>>
	constexpr uint64_t bisect(const T &p_value, bool p_before, Comparator compare = Comparator()) const;
};

template <typename T>
constexpr int64_t Span<T>::find(const T &p_val, uint64_t p_from) const {
	for (uint64_t i = p_from; i < size(); i++) {
		if (ptr()[i] == p_val) {
			return i;
		}
	}
	return -1;
}

template <typename T>
constexpr int64_t Span<T>::find_sequence(const Span<T> &p_span, uint64_t p_from) const {
	for (uint64_t i = p_from; i <= size() - p_span.size(); i++) {
		bool found = true;
		for (uint64_t j = 0; j < p_span.size(); j++) {
			if (ptr()[i + j] != p_span.ptr()[j]) {