Slight refactor of jump collapsing code

This commit is contained in:
Maxime Coste 2018-01-12 07:50:52 +11:00
parent 827aab1386
commit 2366af29e2

View File

@ -1655,15 +1655,16 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func)
} }
else else
{ {
const bool collapse_jumps = not draft and (bool)parser.get_switch("collapse-jumps"); Optional<JumpList> original_jump_list;
SelectionList jump = c.selections(); if (not draft and (bool)parser.get_switch("collapse-jumps"))
JumpList original_jump_list = collapse_jumps ? c.jump_list() : JumpList{}; original_jump_list = c.jump_list();
SelectionList jump = c.selections();
func(parser, c); func(parser, c);
if (collapse_jumps and c.jump_list() != original_jump_list) if (original_jump_list and c.jump_list() != *original_jump_list)
{ {
c.jump_list() = std::move(original_jump_list); c.jump_list() = std::move(*original_jump_list);
c.jump_list().push(std::move(jump)); c.jump_list().push(std::move(jump));
} }
} }