summaryrefslogtreecommitdiff
path: root/src/regex_impl.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-03-18 22:25:21 +1100
committerMaxime Coste <mawww@kakoune.org>2024-03-21 19:18:20 +1100
commitca7471c25d3e0f8dbe48bfec7f6c9af1cb6b34ae (patch)
tree8c649e7778992da0a134d695357aadb009f6f331 /src/regex_impl.hh
parentee364d911f8218d4bff937a1f4b75ecbe122d1f4 (diff)
Compute StartDesc with an offset to effective start
This means `.{2,4}foo` will now consider 4 or less before f as a start candidate instead of every characters
Diffstat (limited to 'src/regex_impl.hh')
-rw-r--r--src/regex_impl.hh7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/regex_impl.hh b/src/regex_impl.hh
index 80d41dbf..8f11f1af 100644
--- a/src/regex_impl.hh
+++ b/src/regex_impl.hh
@@ -153,6 +153,8 @@ struct CompiledRegex : RefCountable, UseMemoryDomain<MemoryDomain::Regex>
struct StartDesc : UseMemoryDomain<MemoryDomain::Regex>
{
static constexpr Codepoint count = 256;
+ using OffsetLimits = std::numeric_limits<uint8_t>;
+ uint8_t offset = 0;
bool map[count];
};
@@ -531,15 +533,16 @@ private:
}
}
- static Iterator find_next_start(Iterator pos, const ExecConfig& config, const StartDesc& start_desc)
+ static Iterator find_next_start(Iterator start, const ExecConfig& config, const StartDesc& start_desc)
{
+ auto pos = start;
while (pos != config.end)
{
static_assert(StartDesc::count <= 256, "start desc should be ascii only");
if constexpr (forward)
{
if (start_desc.map[static_cast<unsigned char>(*pos)])
- return pos;
+ return utf8::advance(pos, start, -CharCount(start_desc.offset));
++pos;
}
else