1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 17:02:06 +03:00

Regex: smarter handling of start chars computation for character class

This commit is contained in:
Maxime Coste 2017-11-30 14:19:41 +08:00
parent 839da764e7
commit c1f0efa3f4

View File

@ -891,10 +891,23 @@ private:
case ParsedRegex::Class:
{
auto& character_class = m_parsed_regex.character_classes[node.value];
for (Codepoint cp = 0; cp < CompiledRegex::StartChars::count; ++cp)
if (character_class.ctypes == CharacterType::None and not character_class.negative)
{
if (is_character_class(character_class, cp))
start_chars.map[cp] = true;
for (auto& range : character_class.ranges)
{
auto min = std::min(CompiledRegex::StartChars::other, range.min);
auto max = std::min(CompiledRegex::StartChars::other, range.max);
for (Codepoint cp = min; cp <= max; ++cp)
start_chars.map[cp] = true;
}
}
else
{
for (Codepoint cp = 0; cp < CompiledRegex::StartChars::other; ++cp)
{
if (start_chars.map[cp] or is_character_class(character_class, cp))
start_chars.map[cp] = true;
}
}
start_chars.map[CompiledRegex::StartChars::other] = true;
return node.quantifier.allows_none();