summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-10-21 10:30:35 +0800
committerMaxime Coste <mawww@kakoune.org>2017-11-01 14:05:15 +0800
commit6e0275e5507fcb18443618bf4e27aa06ba7b4d1a (patch)
tree7d6232140336d493d4beda96895429f5df90186a /src
parent9e15207d2a59e5117242acd29d8dbe365a2a93fd (diff)
Regex: small code cleanup in the Save compilation code
Diffstat (limited to 'src')
-rw-r--r--src/regex_impl.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/regex_impl.cc b/src/regex_impl.cc
index ed17d0de..e640add5 100644
--- a/src/regex_impl.cc
+++ b/src/regex_impl.cc
@@ -634,9 +634,10 @@ private:
const auto start_pos = m_program.instructions.size();
const bool ignore_case = node->ignore_case;
- const Codepoint capture = (node->op == ParsedRegex::Alternation or node->op == ParsedRegex::Sequence) ? node->value : -1;
- if (capture != -1 and (capture == 0 or not (m_flags & RegexCompileFlags::NoSubs)))
- push_inst(CompiledRegex::Save, capture * 2 + (m_forward ? 0 : 1));
+ const bool save = (node->op == ParsedRegex::Alternation or node->op == ParsedRegex::Sequence) and
+ (node->value == 0 or (node->value != -1 and not (m_flags & RegexCompileFlags::NoSubs)));
+ if (save)
+ push_inst(CompiledRegex::Save, node->value * 2 + (m_forward ? 0 : 1));
Vector<uint32_t> goto_inner_end_offsets;
switch (node->op)
@@ -743,8 +744,8 @@ private:
for (auto& offset : goto_inner_end_offsets)
m_program.instructions[offset].param = m_program.instructions.size();
- if (capture != -1 and (capture == 0 or not (m_flags & RegexCompileFlags::NoSubs)))
- push_inst(CompiledRegex::Save, capture * 2 + (m_forward ? 1 : 0));
+ if (save)
+ push_inst(CompiledRegex::Save, node->value * 2 + (m_forward ? 1 : 0));
return start_pos;
}