1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 08:57:47 +00:00

Everywhere: Pass AK::StringView by value

This commit is contained in:
Andreas Kling 2021-11-11 00:55:02 +01:00
parent ad5d217e76
commit 8b1108e485
392 changed files with 978 additions and 978 deletions

View file

@ -105,7 +105,7 @@ static char const* character_class_name(CharClass ch_class)
}
}
static void advance_string_position(MatchState& state, RegexStringView const& view, Optional<u32> code_point = {})
static void advance_string_position(MatchState& state, RegexStringView view, Optional<u32> code_point = {})
{
++state.string_position;
@ -119,13 +119,13 @@ static void advance_string_position(MatchState& state, RegexStringView const& vi
}
}
static void advance_string_position(MatchState& state, RegexStringView const&, RegexStringView const& advance_by)
static void advance_string_position(MatchState& state, RegexStringView, RegexStringView advance_by)
{
state.string_position += advance_by.length();
state.string_position_in_code_units += advance_by.length_in_code_units();
}
static void reverse_string_position(MatchState& state, RegexStringView const& view, size_t amount)
static void reverse_string_position(MatchState& state, RegexStringView view, size_t amount)
{
VERIFY(state.string_position >= amount);
state.string_position -= amount;
@ -603,7 +603,7 @@ ALWAYS_INLINE void OpCode_Compare::compare_char(MatchInput const& input, MatchSt
}
}
ALWAYS_INLINE bool OpCode_Compare::compare_string(MatchInput const& input, MatchState& state, RegexStringView const& str, bool& had_zero_length_match)
ALWAYS_INLINE bool OpCode_Compare::compare_string(MatchInput const& input, MatchState& state, RegexStringView str, bool& had_zero_length_match)
{
if (state.string_position + str.length() > input.view.length()) {
if (str.is_empty()) {

View file

@ -235,7 +235,7 @@ public:
empend(capture_groups_count);
}
void insert_bytecode_group_capture_right(size_t capture_groups_count, StringView const& name)
void insert_bytecode_group_capture_right(size_t capture_groups_count, StringView name)
{
empend(static_cast<ByteCodeValueType>(OpCodeId::SaveRightNamedCaptureGroup));
empend(reinterpret_cast<ByteCodeValueType>(name.characters_without_null_termination()));
@ -507,7 +507,7 @@ public:
OpCode& get_opcode(MatchState& state) const;
private:
void insert_string(StringView const& view)
void insert_string(StringView view)
{
empend((ByteCodeValueType)view.length());
for (size_t i = 0; i < view.length(); ++i)
@ -752,7 +752,7 @@ public:
private:
ALWAYS_INLINE static void compare_char(MatchInput const& input, MatchState& state, u32 ch1, bool inverse, bool& inverse_matched);
ALWAYS_INLINE static bool compare_string(MatchInput const& input, MatchState& state, RegexStringView const& str, bool& had_zero_length_match);
ALWAYS_INLINE static bool compare_string(MatchInput const& input, MatchState& state, RegexStringView str, bool& had_zero_length_match);
ALWAYS_INLINE static void compare_character_class(MatchInput const& input, MatchState& state, CharClass character_class, u32 ch, bool inverse, bool& inverse_matched);
ALWAYS_INLINE static void compare_character_range(MatchInput const& input, MatchState& state, u32 from, u32 to, u32 ch, bool inverse, bool& inverse_matched);
ALWAYS_INLINE static void compare_property(MatchInput const& input, MatchState& state, Unicode::Property property, bool inverse, bool& inverse_matched);

View file

@ -52,7 +52,7 @@ public:
}
TokenType type() const { return m_type; }
StringView const& value() const { return m_value; }
StringView value() const { return m_value; }
size_t position() const { return m_position; }
char const* name() const;

View file

@ -57,7 +57,7 @@ public:
explicit RegexStringView(String&&) = delete;
StringView const& string_view() const
StringView string_view() const
{
return m_view.get<StringView>();
}
@ -280,7 +280,7 @@ public:
size_t code_unit_offset_of(size_t code_point_index) const
{
return m_view.visit(
[&](StringView const& view) -> u32 {
[&](StringView view) -> u32 {
Utf8View utf8_view { view };
return utf8_view.byte_offset_of(code_point_index);
},
@ -316,7 +316,7 @@ public:
[&](StringView view) { return view == string; });
}
bool operator==(StringView const& string) const
bool operator==(StringView string) const
{
return m_view.visit(
[&](Utf32View) { return to_string() == string; },
@ -325,7 +325,7 @@ public:
[&](StringView view) { return view == string; });
}
bool operator!=(StringView const& other) const
bool operator!=(StringView other) const
{
return !(*this == other);
}
@ -374,12 +374,12 @@ public:
return !(*this == other);
}
bool equals(RegexStringView const& other) const
bool equals(RegexStringView other) const
{
return other.m_view.visit([&](auto const& view) { return operator==(view); });
}
bool equals_ignoring_case(RegexStringView const& other) const
bool equals_ignoring_case(RegexStringView other) const
{
// FIXME: Implement equals_ignoring_case() for unicode.
return m_view.visit(
@ -396,7 +396,7 @@ public:
[](auto&) -> bool { TODO(); });
}
bool starts_with(StringView const& str) const
bool starts_with(StringView str) const
{
return m_view.visit(
[&](Utf32View) -> bool {
@ -536,7 +536,7 @@ using regex::RegexStringView;
template<>
struct AK::Formatter<regex::RegexStringView> : Formatter<StringView> {
void format(FormatBuilder& builder, regex::RegexStringView const& value)
void format(FormatBuilder& builder, regex::RegexStringView value)
{
auto string = value.to_string();
return Formatter<StringView>::format(builder, string);

View file

@ -100,7 +100,7 @@ String Regex<Parser>::error_string(Optional<String> message) const
}
template<typename Parser>
RegexResult Matcher<Parser>::match(RegexStringView const& view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options) const
RegexResult Matcher<Parser>::match(RegexStringView view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options) const
{
AllOptions options = m_regex_options | regex_options.value_or({}).value();

View file

@ -60,7 +60,7 @@ public:
}
~Matcher() = default;
RegexResult match(RegexStringView const&, Optional<typename ParserTraits<Parser>::OptionsType> = {}) const;
RegexResult match(RegexStringView, Optional<typename ParserTraits<Parser>::OptionsType> = {}) const;
RegexResult match(Vector<RegexStringView> const&, Optional<typename ParserTraits<Parser>::OptionsType> = {}) const;
typename ParserTraits<Parser>::OptionsType options() const
@ -100,7 +100,7 @@ public:
void print_bytecode(FILE* f = stdout) const;
String error_string(Optional<String> message = {}) const;
RegexResult match(RegexStringView const& view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
RegexResult match(RegexStringView view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
if (!matcher || parser_result.error != Error::NoError)
return {};
@ -114,7 +114,7 @@ public:
return matcher->match(views, regex_options);
}
String replace(RegexStringView const& view, StringView const& replacement_pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
String replace(RegexStringView view, StringView replacement_pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
if (!matcher || parser_result.error != Error::NoError)
return {};
@ -155,7 +155,7 @@ public:
// FIXME: replace(Vector<RegexStringView> const , ...)
RegexResult search(RegexStringView const& view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
RegexResult search(RegexStringView view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
if (!matcher || parser_result.error != Error::NoError)
return {};
@ -187,7 +187,7 @@ public:
return matcher->match(views, options);
}
bool match(RegexStringView const& view, RegexResult& m, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
bool match(RegexStringView view, RegexResult& m, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
m = match(view, regex_options);
return m.success;
@ -199,7 +199,7 @@ public:
return m.success;
}
bool search(RegexStringView const& view, RegexResult& m, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
bool search(RegexStringView view, RegexResult& m, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
m = search(view, regex_options);
return m.success;
@ -211,7 +211,7 @@ public:
return m.success;
}
bool has_match(RegexStringView const& view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
bool has_match(RegexStringView view, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {}) const
{
if (!matcher || parser_result.error != Error::NoError)
return false;
@ -236,7 +236,7 @@ private:
// free standing functions for match, search and has_match
template<class Parser>
RegexResult match(RegexStringView const& view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
RegexResult match(RegexStringView view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
{
return pattern.match(view, regex_options);
}
@ -248,7 +248,7 @@ RegexResult match(Vector<RegexStringView> const& view, Regex<Parser>& pattern, O
}
template<class Parser>
bool match(RegexStringView const& view, Regex<Parser>& pattern, RegexResult&, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
bool match(RegexStringView view, Regex<Parser>& pattern, RegexResult&, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
{
return pattern.match(view, regex_options);
}
@ -260,7 +260,7 @@ bool match(Vector<RegexStringView> const& view, Regex<Parser>& pattern, RegexRes
}
template<class Parser>
RegexResult search(RegexStringView const& view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
RegexResult search(RegexStringView view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
{
return pattern.search(view, regex_options);
}
@ -272,7 +272,7 @@ RegexResult search(Vector<RegexStringView> const& views, Regex<Parser>& pattern,
}
template<class Parser>
bool search(RegexStringView const& view, Regex<Parser>& pattern, RegexResult&, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
bool search(RegexStringView view, Regex<Parser>& pattern, RegexResult&, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
{
return pattern.search(view, regex_options);
}
@ -284,7 +284,7 @@ bool search(Vector<RegexStringView> const& views, Regex<Parser>& pattern, RegexR
}
template<class Parser>
bool has_match(RegexStringView const& view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
bool has_match(RegexStringView view, Regex<Parser>& pattern, Optional<typename ParserTraits<Parser>::OptionsType> regex_options = {})
{
return pattern.has_match(view, regex_options);
}

View file

@ -1139,7 +1139,7 @@ StringView ECMA262Parser::read_digits_as_string(ReadDigitsInitialZeroState initi
size_t offset = 0;
auto start_token = m_parser_state.current_token;
while (match(TokenType::Char)) {
auto& c = m_parser_state.current_token.value();
auto const c = m_parser_state.current_token.value();
if (max_count > 0 && count >= max_count)
break;