diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-07-11 20:18:40 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-12 23:11:35 +0200 |
commit | fbc771efe99ef6c24fa6657f28bcfec7300da61e (patch) | |
tree | cb9bb5cd1604982edc1062a342f915829f5da1f7 /Userland/Libraries/LibRegex | |
parent | c8585b77d263d15807231cb8bd1345d2591b9495 (diff) | |
download | serenity-fbc771efe99ef6c24fa6657f28bcfec7300da61e.zip |
Everywhere: Use default StringView constructor over nullptr
While null StringViews are just as bad, these prevent the removal of
StringView(char const*) as that constructor accepts a nullptr.
No functional changes.
Diffstat (limited to 'Userland/Libraries/LibRegex')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexByteCode.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexLexer.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexLexer.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexParser.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibRegex/RegexParser.h | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp index be5f5a8533..f40d1c25d2 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.cpp +++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp @@ -855,7 +855,7 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput> Vector<String> result; size_t offset { state().instruction_position + 3 }; - RegexStringView view = ((input.has_value()) ? input.value().view : nullptr); + RegexStringView view = ((input.has_value()) ? input.value().view : StringView {}); for (size_t i = 0; i < arguments_count(); ++i) { auto compare_type = (CharacterCompareType)m_bytecode->at(offset++); diff --git a/Userland/Libraries/LibRegex/RegexLexer.cpp b/Userland/Libraries/LibRegex/RegexLexer.cpp index 671e2cb4fa..b294271688 100644 --- a/Userland/Libraries/LibRegex/RegexLexer.cpp +++ b/Userland/Libraries/LibRegex/RegexLexer.cpp @@ -32,7 +32,7 @@ char const* Token::name() const } Lexer::Lexer() - : GenericLexer(StringView { nullptr }) + : GenericLexer(StringView {}) { } @@ -62,7 +62,7 @@ char Lexer::consume() void Lexer::reset() { m_index = 0; - m_current_token = { TokenType::Eof, 0, StringView(nullptr) }; + m_current_token = { TokenType::Eof, 0, {} }; m_previous_position = 0; } @@ -178,7 +178,7 @@ Token Lexer::next() return emit_token(TokenType::Char); } - return Token(TokenType::Eof, m_index, nullptr); + return Token(TokenType::Eof, m_index, {}); } } diff --git a/Userland/Libraries/LibRegex/RegexLexer.h b/Userland/Libraries/LibRegex/RegexLexer.h index 0c42759069..01c086b2c3 100644 --- a/Userland/Libraries/LibRegex/RegexLexer.h +++ b/Userland/Libraries/LibRegex/RegexLexer.h @@ -61,7 +61,7 @@ public: private: TokenType m_type { TokenType::Eof }; size_t m_position { 0 }; - StringView m_value { nullptr }; + StringView m_value {}; }; class Lexer : public GenericLexer { @@ -77,7 +77,7 @@ public: private: size_t m_previous_position { 0 }; - Token m_current_token { TokenType::Eof, 0, StringView(nullptr) }; + Token m_current_token { TokenType::Eof, 0, {} }; }; } diff --git a/Userland/Libraries/LibRegex/RegexParser.cpp b/Userland/Libraries/LibRegex/RegexParser.cpp index 9ffec9f0a2..bef0ea344b 100644 --- a/Userland/Libraries/LibRegex/RegexParser.cpp +++ b/Userland/Libraries/LibRegex/RegexParser.cpp @@ -169,7 +169,7 @@ ALWAYS_INLINE void Parser::reset() m_parser_state.lexer.reset(); m_parser_state.current_token = m_parser_state.lexer.next(); m_parser_state.error = Error::NoError; - m_parser_state.error_token = { TokenType::Eof, 0, StringView(nullptr) }; + m_parser_state.error_token = { TokenType::Eof, 0, {} }; m_parser_state.capture_group_minimum_lengths.clear(); m_parser_state.capture_groups_count = 0; m_parser_state.named_capture_groups_count = 0; diff --git a/Userland/Libraries/LibRegex/RegexParser.h b/Userland/Libraries/LibRegex/RegexParser.h index 3610d3c72a..01f7fae268 100644 --- a/Userland/Libraries/LibRegex/RegexParser.h +++ b/Userland/Libraries/LibRegex/RegexParser.h @@ -101,7 +101,7 @@ protected: Lexer& lexer; Token current_token; Error error = Error::NoError; - Token error_token { TokenType::Eof, 0, StringView(nullptr) }; + Token error_token { TokenType::Eof, 0, {} }; ByteCode bytecode; size_t capture_groups_count { 0 }; size_t named_capture_groups_count { 0 }; |