mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-04 05:19:58 +03:00
Shell: Avoid moving AK::Function instances while inside them
This commit is contained in:
parent
d954c11f66
commit
fdfa5c0bc7
Notes:
sideshowbarker
2024-07-18 17:46:29 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/fdfa5c0bc72 Pull-request: https://github.com/SerenityOS/serenity/pull/7278
@ -2037,7 +2037,7 @@ bool Parser::parse_heredoc_entries()
|
||||
// until we find a line that contains the key
|
||||
auto end_condition = move(m_end_condition);
|
||||
found_key = false;
|
||||
set_end_condition([this, end = record.end, &found_key] {
|
||||
set_end_condition(make<Function<bool()>>([this, end = record.end, &found_key] {
|
||||
if (found_key)
|
||||
return true;
|
||||
auto offset = current_position();
|
||||
@ -2060,7 +2060,7 @@ bool Parser::parse_heredoc_entries()
|
||||
}
|
||||
restore_to(offset.offset, offset.line);
|
||||
return false;
|
||||
});
|
||||
}));
|
||||
|
||||
auto expr = parse_doublequoted_string_inner();
|
||||
set_end_condition(move(end_condition));
|
||||
|
@ -94,10 +94,10 @@ private:
|
||||
template<typename A, typename... Args>
|
||||
NonnullRefPtr<A> create(Args... args);
|
||||
|
||||
void set_end_condition(Function<bool()> condition) { m_end_condition = move(condition); }
|
||||
void set_end_condition(OwnPtr<Function<bool()>> condition) { m_end_condition = move(condition); }
|
||||
bool at_end() const
|
||||
{
|
||||
if (m_end_condition && m_end_condition())
|
||||
if (m_end_condition && (*m_end_condition)())
|
||||
return true;
|
||||
return m_input.length() <= m_offset;
|
||||
}
|
||||
@ -159,7 +159,7 @@ private:
|
||||
Vector<size_t> m_rule_start_offsets;
|
||||
Vector<AST::Position::Line> m_rule_start_lines;
|
||||
|
||||
Function<bool()> m_end_condition;
|
||||
OwnPtr<Function<bool()>> m_end_condition;
|
||||
Vector<HeredocInitiationRecord> m_heredoc_initiations;
|
||||
Vector<char> m_extra_chars_not_allowed_in_barewords;
|
||||
bool m_is_in_brace_expansion_spec { false };
|
||||
|
Loading…
Reference in New Issue
Block a user