aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/simd/index_of.h
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-07 18:29:21 +0300
commitdcfe11a7588fcd42471159453810abc9b7720a57 (patch)
treec32a77266028e73ca2382b96c96f8438a5fcd621 /vendor/libghostty-vt/src/simd/index_of.h
parent2dfed860103c4e4505ac7f25def9fe37da1e1e6a (diff)
build: update libghostty-vt vendor
vendor ghostty 063ac3e and remove the musl libc++ link workaround. expose the new selection formatter and hyperlink uri apis for follow-up rendering work. add manual artifact validation for static linux builds.
Diffstat (limited to 'vendor/libghostty-vt/src/simd/index_of.h')
-rw-r--r--vendor/libghostty-vt/src/simd/index_of.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/vendor/libghostty-vt/src/simd/index_of.h b/vendor/libghostty-vt/src/simd/index_of.h
index 531af9f8..172c9357 100644
--- a/vendor/libghostty-vt/src/simd/index_of.h
+++ b/vendor/libghostty-vt/src/simd/index_of.h
@@ -7,8 +7,7 @@
#include <hwy/highway.h>
-#include <cstddef>
-#include <optional>
+#include <stddef.h>
HWY_BEFORE_NAMESPACE();
namespace ghostty {
@@ -16,12 +15,16 @@ namespace HWY_NAMESPACE {
namespace hn = hwy::HWY_NAMESPACE;
+// Sentinel value returned by IndexOfChunk when no match is found.
+static constexpr size_t kNotFound = static_cast<size_t>(-1);
+
// Return the index of the first occurrence of `needle` in `input`, where
-// the input and needle are already loaded into vectors.
+// the input and needle are already loaded into vectors. Returns kNotFound
+// if no match is found.
template <class D, typename T = hn::TFromD<D>>
-std::optional<size_t> IndexOfChunk(D d,
- hn::Vec<D> needle_vec,
- hn::Vec<D> input_vec) {
+size_t IndexOfChunk(D d,
+ hn::Vec<D> needle_vec,
+ hn::Vec<D> input_vec) {
// Compare the input vector with the needle vector. This produces
// a vector where each lane is 0xFF if the corresponding lane in
// `input_vec` is equal to the corresponding lane in `needle_vec`.
@@ -32,9 +35,9 @@ std::optional<size_t> IndexOfChunk(D d,
// If we found a match, return the index into the input.
if (pos >= 0) {
- return std::optional<size_t>(static_cast<size_t>(pos));
+ return static_cast<size_t>(pos);
} else {
- return std::nullopt;
+ return kNotFound;
}
}
@@ -58,8 +61,9 @@ size_t IndexOfImpl(D d, T needle, const T* HWY_RESTRICT input, size_t count) {
for (; i + N <= count; i += N) {
// Load the N elements from our input into a vector and check the chunk.
const hn::Vec<D> input_vec = hn::LoadU(d, input + i);
- if (auto pos = IndexOfChunk(d, needle_vec, input_vec)) {
- return i + pos.value();
+ const size_t pos = IndexOfChunk(d, needle_vec, input_vec);
+ if (pos != kNotFound) {
+ return i + pos;
}
}