mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 11:37:45 +00:00
Everywhere: Pass AK::StringView by value
This commit is contained in:
parent
ad5d217e76
commit
8b1108e485
392 changed files with 978 additions and 978 deletions
|
@ -51,7 +51,7 @@ RecursionDecision Document::walk(Visitor& visitor) const
|
|||
return m_container->walk(visitor);
|
||||
}
|
||||
|
||||
OwnPtr<Document> Document::parse(const StringView& str)
|
||||
OwnPtr<Document> Document::parse(StringView str)
|
||||
{
|
||||
const Vector<StringView> lines_vec = str.lines();
|
||||
LineIterator lines(lines_vec.begin());
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
*/
|
||||
RecursionDecision walk(Visitor&) const;
|
||||
|
||||
static OwnPtr<Document> parse(const StringView&);
|
||||
static OwnPtr<Document> parse(StringView);
|
||||
|
||||
private:
|
||||
OwnPtr<ContainerBlock> m_container;
|
||||
|
|
|
@ -50,7 +50,7 @@ OwnPtr<Heading> Heading::parse(LineIterator& lines)
|
|||
if (lines.is_end())
|
||||
return {};
|
||||
|
||||
const StringView& line = *lines;
|
||||
StringView line = *lines;
|
||||
size_t level;
|
||||
|
||||
for (level = 0; level < line.length(); level++) {
|
||||
|
|
|
@ -39,7 +39,7 @@ OwnPtr<HorizontalRule> HorizontalRule::parse(LineIterator& lines)
|
|||
if (lines.is_end())
|
||||
return {};
|
||||
|
||||
const StringView& line = *lines;
|
||||
StringView line = *lines;
|
||||
|
||||
if (line.length() < 3)
|
||||
return {};
|
||||
|
|
|
@ -16,7 +16,7 @@ void LineIterator::reset_ignore_prefix()
|
|||
}
|
||||
}
|
||||
|
||||
Optional<StringView> LineIterator::match_context(StringView const& line) const
|
||||
Optional<StringView> LineIterator::match_context(StringView line) const
|
||||
{
|
||||
bool is_ws = line.is_whitespace();
|
||||
size_t offset = 0;
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
private:
|
||||
void reset_ignore_prefix();
|
||||
Optional<StringView> match_context(StringView const& line) const;
|
||||
Optional<StringView> match_context(StringView line) const;
|
||||
|
||||
Vector<StringView>::ConstIterator m_iterator;
|
||||
Vector<Context> m_context_stack;
|
||||
|
|
|
@ -85,7 +85,7 @@ OwnPtr<List> List::parse(LineIterator& lines)
|
|||
|
||||
size_t offset = 0;
|
||||
|
||||
const StringView& line = *lines;
|
||||
StringView line = *lines;
|
||||
|
||||
bool appears_unordered = false;
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ RecursionDecision Text::walk(Visitor& visitor) const
|
|||
return m_node->walk(visitor);
|
||||
}
|
||||
|
||||
Text Text::parse(StringView const& str)
|
||||
Text Text::parse(StringView str)
|
||||
{
|
||||
Text text;
|
||||
auto const tokens = tokenize(str);
|
||||
|
@ -260,7 +260,7 @@ Text Text::parse(StringView const& str)
|
|||
return text;
|
||||
}
|
||||
|
||||
static bool flanking(StringView const& str, size_t start, size_t end, int dir)
|
||||
static bool flanking(StringView str, size_t start, size_t end, int dir)
|
||||
{
|
||||
ssize_t next = ((dir > 0) ? end : start) + dir;
|
||||
if (next < 0 || next >= (ssize_t)str.length())
|
||||
|
@ -279,7 +279,7 @@ static bool flanking(StringView const& str, size_t start, size_t end, int dir)
|
|||
return isspace(str[prev]) || ispunct(str[prev]);
|
||||
}
|
||||
|
||||
Vector<Text::Token> Text::tokenize(StringView const& str)
|
||||
Vector<Text::Token> Text::tokenize(StringView str)
|
||||
{
|
||||
Vector<Token> tokens;
|
||||
StringBuilder current_token;
|
||||
|
@ -306,14 +306,14 @@ Vector<Text::Token> Text::tokenize(StringView const& str)
|
|||
bool in_space = false;
|
||||
|
||||
for (size_t offset = 0; offset < str.length(); ++offset) {
|
||||
auto has = [&](StringView const& seq) {
|
||||
auto has = [&](StringView seq) {
|
||||
if (offset + seq.length() > str.length())
|
||||
return false;
|
||||
|
||||
return str.substring_view(offset, seq.length()) == seq;
|
||||
};
|
||||
|
||||
auto expect = [&](StringView const& seq) {
|
||||
auto expect = [&](StringView seq) {
|
||||
VERIFY(has(seq));
|
||||
flush_token();
|
||||
current_token.append(seq);
|
||||
|
|
|
@ -73,13 +73,13 @@ public:
|
|||
String text;
|
||||
bool collapsible;
|
||||
|
||||
TextNode(StringView const& text)
|
||||
TextNode(StringView text)
|
||||
: text(text)
|
||||
, collapsible(true)
|
||||
{
|
||||
}
|
||||
|
||||
TextNode(StringView const& text, bool collapsible)
|
||||
TextNode(StringView text, bool collapsible)
|
||||
: text(text)
|
||||
, collapsible(collapsible)
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
String render_for_terminal() const;
|
||||
RecursionDecision walk(Visitor&) const;
|
||||
|
||||
static Text parse(StringView const&);
|
||||
static Text parse(StringView);
|
||||
|
||||
private:
|
||||
struct Token {
|
||||
|
@ -157,10 +157,10 @@ private:
|
|||
{
|
||||
return data[0] == ' ';
|
||||
}
|
||||
bool operator==(StringView const& str) const { return str == data; }
|
||||
bool operator==(StringView str) const { return str == data; }
|
||||
};
|
||||
|
||||
static Vector<Token> tokenize(StringView const&);
|
||||
static Vector<Token> tokenize(StringView);
|
||||
|
||||
static bool can_open(Token const& opening);
|
||||
static bool can_close_for(Token const& opening, Token const& closing);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue