diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-12-06 17:03:29 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-06 15:38:40 +0100 |
commit | 86811683b071415c47668781ab5fd7241f85ea55 (patch) | |
tree | 00e8352fc146daedf3c1cee29aca44e01f3571fd /Libraries | |
parent | 19bf7734a49c1f86247c6b52c4831cf0575c6180 (diff) | |
download | serenity-86811683b071415c47668781ab5fd7241f85ea55.zip |
LibRegex: Remove Lexer::slice_back() and just use StringViews
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibRegex/RegexLexer.h | 2 | ||||
-rw-r--r-- | Libraries/LibRegex/RegexParser.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Libraries/LibRegex/RegexLexer.h b/Libraries/LibRegex/RegexLexer.h index 7a54dea091..959fa50c33 100644 --- a/Libraries/LibRegex/RegexLexer.h +++ b/Libraries/LibRegex/RegexLexer.h @@ -94,8 +94,6 @@ public: bool try_skip(char); char skip(); - StringView slice_back(size_t offset) const { return m_source.substring_view(m_position - offset - 1, offset); } - private: ALWAYS_INLINE char peek(size_t offset = 0) const; ALWAYS_INLINE void consume(); diff --git a/Libraries/LibRegex/RegexParser.cpp b/Libraries/LibRegex/RegexParser.cpp index aa22be74b2..ca86012f53 100644 --- a/Libraries/LibRegex/RegexParser.cpp +++ b/Libraries/LibRegex/RegexParser.cpp @@ -803,6 +803,7 @@ Optional<unsigned> ECMA262Parser::read_digits(ECMA262Parser::ReadDigitsInitialZe int count = 0; size_t offset = 0; + auto start_token = m_parser_state.current_token; while (match(TokenType::Char)) { auto c = m_parser_state.current_token.value(); if (follow_policy == ReadDigitFollowPolicy::DisallowDigit) { @@ -826,7 +827,7 @@ Optional<unsigned> ECMA262Parser::read_digits(ECMA262Parser::ReadDigitsInitialZe ++count; } - auto str = m_parser_state.lexer.slice_back(offset); + StringView str { start_token.value().characters_without_null_termination(), offset }; if (hex) return AK::StringUtils::convert_to_uint_from_hex(str); @@ -1371,6 +1372,7 @@ StringView ECMA262Parser::read_capture_group_specifier(bool take_starting_angle_ if (take_starting_angle_bracket && !consume("<")) return {}; + auto start_token = m_parser_state.current_token; size_t offset = 0; while (match(TokenType::Char)) { auto c = m_parser_state.current_token.value(); @@ -1379,7 +1381,7 @@ StringView ECMA262Parser::read_capture_group_specifier(bool take_starting_angle_ offset += consume().value().length(); } - auto name = m_parser_state.lexer.slice_back(offset); + StringView name { start_token.value().characters_without_null_termination(), offset }; if (!consume(">") || name.is_empty()) set_error(Error::InvalidNameForCaptureGroup); |