LibRegex: Port remaining DeprecatedFlyString to ByteString

This commit is contained in:
Kenneth Myhra 2025-03-30 17:27:52 +02:00 committed by Andreas Kling
parent cb722ca18b
commit aab3fbe254
Notes: github-actions[bot] 2025-04-01 10:50:59 +00:00
2 changed files with 7 additions and 8 deletions

View file

@ -11,7 +11,6 @@
#include <AK/ByteString.h> #include <AK/ByteString.h>
#include <AK/CharacterTypes.h> #include <AK/CharacterTypes.h>
#include <AK/Debug.h> #include <AK/Debug.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/GenericLexer.h> #include <AK/GenericLexer.h>
#include <AK/ScopeGuard.h> #include <AK/ScopeGuard.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
@ -982,7 +981,7 @@ bool ECMA262Parser::parse_pattern(ByteCode& stack, size_t& match_length_minimum,
return parse_disjunction(stack, match_length_minimum, flags); return parse_disjunction(stack, match_length_minimum, flags);
} }
bool ECMA262Parser::has_duplicate_in_current_alternative(DeprecatedFlyString const& name) bool ECMA262Parser::has_duplicate_in_current_alternative(ByteString const& name)
{ {
auto it = m_parser_state.named_capture_groups.find(name); auto it = m_parser_state.named_capture_groups.find(name);
if (it == m_parser_state.named_capture_groups.end()) if (it == m_parser_state.named_capture_groups.end())
@ -2503,7 +2502,7 @@ bool ECMA262Parser::parse_unicode_property_escape(PropertyEscape& property, bool
[](Empty&) -> bool { VERIFY_NOT_REACHED(); }); [](Empty&) -> bool { VERIFY_NOT_REACHED(); });
} }
DeprecatedFlyString ECMA262Parser::read_capture_group_specifier(bool take_starting_angle_bracket) ByteString ECMA262Parser::read_capture_group_specifier(bool take_starting_angle_bracket)
{ {
static constexpr u32 const REPLACEMENT_CHARACTER = 0xFFFD; static constexpr u32 const REPLACEMENT_CHARACTER = 0xFFFD;
constexpr u32 const ZERO_WIDTH_NON_JOINER { 0x200C }; constexpr u32 const ZERO_WIDTH_NON_JOINER { 0x200C };
@ -2604,7 +2603,7 @@ DeprecatedFlyString ECMA262Parser::read_capture_group_specifier(bool take_starti
builder.append_code_point(code_point); builder.append_code_point(code_point);
} }
DeprecatedFlyString name = builder.to_byte_string(); auto name = builder.to_byte_string();
if (!hit_end || name.is_empty()) if (!hit_end || name.is_empty())
set_error(Error::InvalidNameForCaptureGroup); set_error(Error::InvalidNameForCaptureGroup);

View file

@ -59,7 +59,7 @@ public:
size_t match_length_minimum; size_t match_length_minimum;
Error error; Error error;
Token error_token; Token error_token;
Vector<DeprecatedFlyString> capture_groups; Vector<ByteString> capture_groups;
AllOptions options; AllOptions options;
struct { struct {
@ -117,7 +117,7 @@ protected:
size_t repetition_mark_count { 0 }; size_t repetition_mark_count { 0 };
AllOptions regex_options; AllOptions regex_options;
HashMap<size_t, size_t> capture_group_minimum_lengths; HashMap<size_t, size_t> capture_group_minimum_lengths;
HashMap<DeprecatedFlyString, Vector<NamedCaptureGroup>> named_capture_groups; HashMap<ByteString, Vector<NamedCaptureGroup>> named_capture_groups;
explicit ParserState(Lexer& lexer) explicit ParserState(Lexer& lexer)
: lexer(lexer) : lexer(lexer)
@ -240,7 +240,7 @@ private:
}; };
StringView read_digits_as_string(ReadDigitsInitialZeroState initial_zero = ReadDigitsInitialZeroState::Allow, bool hex = false, int max_count = -1, int min_count = -1); StringView read_digits_as_string(ReadDigitsInitialZeroState initial_zero = ReadDigitsInitialZeroState::Allow, bool hex = false, int max_count = -1, int min_count = -1);
Optional<unsigned> read_digits(ReadDigitsInitialZeroState initial_zero = ReadDigitsInitialZeroState::Allow, bool hex = false, int max_count = -1, int min_count = -1); Optional<unsigned> read_digits(ReadDigitsInitialZeroState initial_zero = ReadDigitsInitialZeroState::Allow, bool hex = false, int max_count = -1, int min_count = -1);
DeprecatedFlyString read_capture_group_specifier(bool take_starting_angle_bracket = false); ByteString read_capture_group_specifier(bool take_starting_angle_bracket = false);
struct Script { struct Script {
Unicode::Script script {}; Unicode::Script script {};
@ -282,7 +282,7 @@ private:
bool parse_invalid_braced_quantifier(); // Note: This function either parses and *fails*, or doesn't parse anything and returns false. bool parse_invalid_braced_quantifier(); // Note: This function either parses and *fails*, or doesn't parse anything and returns false.
Optional<u8> parse_legacy_octal_escape(); Optional<u8> parse_legacy_octal_escape();
bool has_duplicate_in_current_alternative(DeprecatedFlyString const& name); bool has_duplicate_in_current_alternative(ByteString const& name);
size_t ensure_total_number_of_capturing_parenthesis(); size_t ensure_total_number_of_capturing_parenthesis();