mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:07:35 +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
|
@ -32,7 +32,7 @@ String char_for_piece(Chess::Type type)
|
|||
}
|
||||
}
|
||||
|
||||
Chess::Type piece_for_char_promotion(const StringView& str)
|
||||
Chess::Type piece_for_char_promotion(StringView str)
|
||||
{
|
||||
String string = String(str).to_lowercase();
|
||||
if (string == "")
|
||||
|
@ -56,7 +56,7 @@ Color opposing_color(Color color)
|
|||
return (color == Color::White) ? Color::Black : Color::White;
|
||||
}
|
||||
|
||||
Square::Square(const StringView& name)
|
||||
Square::Square(StringView name)
|
||||
{
|
||||
VERIFY(name.length() == 2);
|
||||
char filec = name[0];
|
||||
|
@ -85,7 +85,7 @@ String Square::to_algebraic() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Move::Move(const StringView& long_algebraic)
|
||||
Move::Move(StringView long_algebraic)
|
||||
: from(long_algebraic.substring_view(0, 2))
|
||||
, to(long_algebraic.substring_view(2, 2))
|
||||
, promote_to(piece_for_char_promotion((long_algebraic.length() >= 5) ? long_algebraic.substring_view(4, 1) : ""))
|
||||
|
@ -101,7 +101,7 @@ String Move::to_long_algebraic() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Move Move::from_algebraic(const StringView& algebraic, const Color turn, const Board& board)
|
||||
Move Move::from_algebraic(StringView algebraic, const Color turn, const Board& board)
|
||||
{
|
||||
String move_string = algebraic;
|
||||
Move move({ 50, 50 }, { 50, 50 });
|
||||
|
|
|
@ -26,7 +26,7 @@ enum class Type : u8 {
|
|||
};
|
||||
|
||||
String char_for_piece(Type type);
|
||||
Chess::Type piece_for_char_promotion(const StringView& str);
|
||||
Chess::Type piece_for_char_promotion(StringView str);
|
||||
|
||||
enum class Color : u8 {
|
||||
White,
|
||||
|
@ -57,7 +57,7 @@ constexpr Piece EmptyPiece = { Color::None, Type::None };
|
|||
struct Square {
|
||||
i8 rank; // zero indexed;
|
||||
i8 file;
|
||||
Square(const StringView& name);
|
||||
Square(StringView name);
|
||||
Square(const int& rank, const int& file)
|
||||
: rank(rank)
|
||||
, file(file)
|
||||
|
@ -93,7 +93,7 @@ struct Move {
|
|||
bool is_capture : 1 = false;
|
||||
bool is_ambiguous : 1 = false;
|
||||
Square ambiguous { 50, 50 };
|
||||
Move(const StringView& long_algebraic);
|
||||
Move(StringView long_algebraic);
|
||||
Move(const Square& from, const Square& to, const Type& promote_to = Type::None)
|
||||
: from(from)
|
||||
, to(to)
|
||||
|
@ -102,7 +102,7 @@ struct Move {
|
|||
}
|
||||
bool operator==(const Move& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
|
||||
|
||||
static Move from_algebraic(const StringView& algebraic, const Color turn, const Board& board);
|
||||
static Move from_algebraic(StringView algebraic, const Color turn, const Board& board);
|
||||
String to_long_algebraic() const;
|
||||
String to_algebraic() const;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Chess::UCI {
|
||||
|
||||
UCICommand UCICommand::from_string(const StringView& command)
|
||||
UCICommand UCICommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "uci");
|
||||
|
@ -22,7 +22,7 @@ String UCICommand::to_string() const
|
|||
return "uci\n";
|
||||
}
|
||||
|
||||
DebugCommand DebugCommand::from_string(const StringView& command)
|
||||
DebugCommand DebugCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "debug");
|
||||
|
@ -44,7 +44,7 @@ String DebugCommand::to_string() const
|
|||
}
|
||||
}
|
||||
|
||||
IsReadyCommand IsReadyCommand::from_string(const StringView& command)
|
||||
IsReadyCommand IsReadyCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "isready");
|
||||
|
@ -57,7 +57,7 @@ String IsReadyCommand::to_string() const
|
|||
return "isready\n";
|
||||
}
|
||||
|
||||
SetOptionCommand SetOptionCommand::from_string(const StringView& command)
|
||||
SetOptionCommand SetOptionCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "setoption");
|
||||
|
@ -108,7 +108,7 @@ String SetOptionCommand::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
PositionCommand PositionCommand::from_string(const StringView& command)
|
||||
PositionCommand PositionCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens.size() >= 3);
|
||||
|
@ -144,7 +144,7 @@ String PositionCommand::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
GoCommand GoCommand::from_string(const StringView& command)
|
||||
GoCommand GoCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "go");
|
||||
|
@ -230,7 +230,7 @@ String GoCommand::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
StopCommand StopCommand::from_string(const StringView& command)
|
||||
StopCommand StopCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "stop");
|
||||
|
@ -243,7 +243,7 @@ String StopCommand::to_string() const
|
|||
return "stop\n";
|
||||
}
|
||||
|
||||
IdCommand IdCommand::from_string(const StringView& command)
|
||||
IdCommand IdCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "id");
|
||||
|
@ -277,7 +277,7 @@ String IdCommand::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
UCIOkCommand UCIOkCommand::from_string(const StringView& command)
|
||||
UCIOkCommand UCIOkCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "uciok");
|
||||
|
@ -290,7 +290,7 @@ String UCIOkCommand::to_string() const
|
|||
return "uciok\n";
|
||||
}
|
||||
|
||||
ReadyOkCommand ReadyOkCommand::from_string(const StringView& command)
|
||||
ReadyOkCommand ReadyOkCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "readyok");
|
||||
|
@ -303,7 +303,7 @@ String ReadyOkCommand::to_string() const
|
|||
return "readyok\n";
|
||||
}
|
||||
|
||||
BestMoveCommand BestMoveCommand::from_string(const StringView& command)
|
||||
BestMoveCommand BestMoveCommand::from_string(StringView command)
|
||||
{
|
||||
auto tokens = command.split_view(' ');
|
||||
VERIFY(tokens[0] == "bestmove");
|
||||
|
@ -320,7 +320,7 @@ String BestMoveCommand::to_string() const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
InfoCommand InfoCommand::from_string([[maybe_unused]] const StringView& command)
|
||||
InfoCommand InfoCommand::from_string([[maybe_unused]] StringView command)
|
||||
{
|
||||
// FIXME: Implement this.
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static UCICommand from_string(const StringView& command);
|
||||
static UCICommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static DebugCommand from_string(const StringView& command);
|
||||
static DebugCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -91,21 +91,21 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static IsReadyCommand from_string(const StringView& command);
|
||||
static IsReadyCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
};
|
||||
|
||||
class SetOptionCommand : public Command {
|
||||
public:
|
||||
explicit SetOptionCommand(const StringView& name, Optional<String> value = {})
|
||||
explicit SetOptionCommand(StringView name, Optional<String> value = {})
|
||||
: Command(Command::Type::SetOption)
|
||||
, m_name(name)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
static SetOptionCommand from_string(const StringView& command);
|
||||
static SetOptionCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static PositionCommand from_string(const StringView& command);
|
||||
static PositionCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -145,7 +145,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static GoCommand from_string(const StringView& command);
|
||||
static GoCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static StopCommand from_string(const StringView& command);
|
||||
static StopCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
};
|
||||
|
@ -182,14 +182,14 @@ public:
|
|||
Author,
|
||||
};
|
||||
|
||||
explicit IdCommand(Type field_type, const StringView& value)
|
||||
explicit IdCommand(Type field_type, StringView value)
|
||||
: Command(Command::Type::Id)
|
||||
, m_field_type(field_type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
static IdCommand from_string(const StringView& command);
|
||||
static IdCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static UCIOkCommand from_string(const StringView& command);
|
||||
static UCIOkCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
};
|
||||
|
@ -220,7 +220,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static ReadyOkCommand from_string(const StringView& command);
|
||||
static ReadyOkCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
};
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static BestMoveCommand from_string(const StringView& command);
|
||||
static BestMoveCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
@ -250,7 +250,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static InfoCommand from_string(const StringView& command);
|
||||
static InfoCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue