mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
LibJS: Remember arrow function parsing failures by offset
We don't need to remember these by (line, column, offset). Just the offset should be enough.
This commit is contained in:
parent
d5a0bb9159
commit
2e06d26ddb
Notes:
github-actions[bot]
2024-09-02 13:23:45 +00:00
Author: https://github.com/awesomekling
Commit: 2e06d26ddb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1247
2 changed files with 3 additions and 16 deletions
|
@ -4487,7 +4487,7 @@ Position Parser::position() const
|
||||||
|
|
||||||
bool Parser::try_parse_arrow_function_expression_failed_at_position(Position const& position) const
|
bool Parser::try_parse_arrow_function_expression_failed_at_position(Position const& position) const
|
||||||
{
|
{
|
||||||
auto it = m_token_memoizations.find(position);
|
auto it = m_token_memoizations.find(position.offset);
|
||||||
if (it == m_token_memoizations.end())
|
if (it == m_token_memoizations.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -4496,7 +4496,7 @@ bool Parser::try_parse_arrow_function_expression_failed_at_position(Position con
|
||||||
|
|
||||||
void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position const& position, bool failed)
|
void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position const& position, bool failed)
|
||||||
{
|
{
|
||||||
m_token_memoizations.set(position, { failed });
|
m_token_memoizations.set(position.offset, { failed });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::syntax_error(ByteString const& message, Optional<Position> position)
|
void Parser::syntax_error(ByteString const& message, Optional<Position> position)
|
||||||
|
|
|
@ -334,19 +334,6 @@ private:
|
||||||
ParserState(Lexer, Program::Type);
|
ParserState(Lexer, Program::Type);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PositionKeyTraits {
|
|
||||||
public:
|
|
||||||
static int hash(Position const& position)
|
|
||||||
{
|
|
||||||
return int_hash(position.line) ^ int_hash(position.column);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool equals(Position const& a, Position const& b)
|
|
||||||
{
|
|
||||||
return a.column == b.column && a.line == b.line;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
[[nodiscard]] NonnullRefPtr<Identifier const> create_identifier_and_register_in_current_scope(SourceRange range, DeprecatedFlyString string, Optional<DeclarationKind> = {});
|
[[nodiscard]] NonnullRefPtr<Identifier const> create_identifier_and_register_in_current_scope(SourceRange range, DeprecatedFlyString string, Optional<DeclarationKind> = {});
|
||||||
|
|
||||||
NonnullRefPtr<SourceCode const> m_source_code;
|
NonnullRefPtr<SourceCode const> m_source_code;
|
||||||
|
@ -354,7 +341,7 @@ private:
|
||||||
ParserState m_state;
|
ParserState m_state;
|
||||||
DeprecatedFlyString m_filename;
|
DeprecatedFlyString m_filename;
|
||||||
Vector<ParserState> m_saved_state;
|
Vector<ParserState> m_saved_state;
|
||||||
HashMap<Position, TokenMemoization, PositionKeyTraits> m_token_memoizations;
|
HashMap<size_t, TokenMemoization> m_token_memoizations;
|
||||||
Program::Type m_program_type;
|
Program::Type m_program_type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue