mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -88,7 +88,7 @@ String Square::to_algebraic() const
|
|||
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) : ""))
|
||||
, promote_to(piece_for_char_promotion((long_algebraic.length() >= 5) ? long_algebraic.substring_view(4, 1) : ""sv))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -292,13 +292,13 @@ String Board::to_fen() const
|
|||
|
||||
// 2. Active color
|
||||
VERIFY(m_turn != Color::None);
|
||||
builder.append(m_turn == Color::White ? " w " : " b ");
|
||||
builder.append(m_turn == Color::White ? " w "sv : " b "sv);
|
||||
|
||||
// 3. Castling availability
|
||||
builder.append(m_white_can_castle_kingside ? "K" : "");
|
||||
builder.append(m_white_can_castle_queenside ? "Q" : "");
|
||||
builder.append(m_black_can_castle_kingside ? "k" : "");
|
||||
builder.append(m_black_can_castle_queenside ? "q" : "");
|
||||
builder.append(m_white_can_castle_kingside ? "K"sv : ""sv);
|
||||
builder.append(m_white_can_castle_queenside ? "Q"sv : ""sv);
|
||||
builder.append(m_black_can_castle_kingside ? "k"sv : ""sv);
|
||||
builder.append(m_black_can_castle_queenside ? "q"sv : ""sv);
|
||||
builder.append(" ");
|
||||
|
||||
// 4. En passant target square
|
||||
|
|
|
@ -98,10 +98,10 @@ SetOptionCommand SetOptionCommand::from_string(StringView command)
|
|||
String SetOptionCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("setoption name ");
|
||||
builder.append("setoption name "sv);
|
||||
builder.append(name());
|
||||
if (value().has_value()) {
|
||||
builder.append(" value ");
|
||||
builder.append(" value "sv);
|
||||
builder.append(value().value());
|
||||
}
|
||||
builder.append('\n');
|
||||
|
@ -129,13 +129,13 @@ PositionCommand PositionCommand::from_string(StringView command)
|
|||
String PositionCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("position ");
|
||||
builder.append("position "sv);
|
||||
if (fen().has_value()) {
|
||||
builder.append(fen().value());
|
||||
} else {
|
||||
builder.append("startpos ");
|
||||
builder.append("startpos "sv);
|
||||
}
|
||||
builder.append("moves");
|
||||
builder.append("moves"sv);
|
||||
for (auto& move : moves()) {
|
||||
builder.append(' ');
|
||||
builder.append(move.to_long_algebraic());
|
||||
|
@ -193,10 +193,10 @@ GoCommand GoCommand::from_string(StringView command)
|
|||
String GoCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("go");
|
||||
builder.append("go"sv);
|
||||
|
||||
if (searchmoves.has_value()) {
|
||||
builder.append(" searchmoves");
|
||||
builder.append(" searchmoves"sv);
|
||||
for (auto& move : searchmoves.value()) {
|
||||
builder.append(' ');
|
||||
builder.append(move.to_long_algebraic());
|
||||
|
@ -204,7 +204,7 @@ String GoCommand::to_string() const
|
|||
}
|
||||
|
||||
if (ponder)
|
||||
builder.append(" ponder");
|
||||
builder.append(" ponder"sv);
|
||||
if (wtime.has_value())
|
||||
builder.appendff(" wtime {}", wtime.value());
|
||||
if (btime.has_value())
|
||||
|
@ -224,7 +224,7 @@ String GoCommand::to_string() const
|
|||
if (movetime.has_value())
|
||||
builder.appendff(" movetime {}", movetime.value());
|
||||
if (infinite)
|
||||
builder.append(" infinite");
|
||||
builder.append(" infinite"sv);
|
||||
|
||||
builder.append('\n');
|
||||
return builder.build();
|
||||
|
@ -266,11 +266,11 @@ IdCommand IdCommand::from_string(StringView command)
|
|||
String IdCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("id ");
|
||||
builder.append("id "sv);
|
||||
if (field_type() == Type::Name) {
|
||||
builder.append("name ");
|
||||
builder.append("name "sv);
|
||||
} else {
|
||||
builder.append("author ");
|
||||
builder.append("author "sv);
|
||||
}
|
||||
builder.append(value());
|
||||
builder.append('\n');
|
||||
|
@ -314,7 +314,7 @@ BestMoveCommand BestMoveCommand::from_string(StringView command)
|
|||
String BestMoveCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("bestmove ");
|
||||
builder.append("bestmove "sv);
|
||||
builder.append(move().to_long_algebraic());
|
||||
builder.append('\n');
|
||||
return builder.build();
|
||||
|
|
|
@ -76,27 +76,27 @@ NonnullOwnPtr<Command> Endpoint::read_command()
|
|||
|
||||
if (line == "uci") {
|
||||
return make<UCICommand>(UCICommand::from_string(line));
|
||||
} else if (line.starts_with("debug")) {
|
||||
} else if (line.starts_with("debug"sv)) {
|
||||
return make<DebugCommand>(DebugCommand::from_string(line));
|
||||
} else if (line.starts_with("isready")) {
|
||||
} else if (line.starts_with("isready"sv)) {
|
||||
return make<IsReadyCommand>(IsReadyCommand::from_string(line));
|
||||
} else if (line.starts_with("setoption")) {
|
||||
} else if (line.starts_with("setoption"sv)) {
|
||||
return make<SetOptionCommand>(SetOptionCommand::from_string(line));
|
||||
} else if (line.starts_with("position")) {
|
||||
} else if (line.starts_with("position"sv)) {
|
||||
return make<PositionCommand>(PositionCommand::from_string(line));
|
||||
} else if (line.starts_with("go")) {
|
||||
} else if (line.starts_with("go"sv)) {
|
||||
return make<GoCommand>(GoCommand::from_string(line));
|
||||
} else if (line.starts_with("stop")) {
|
||||
} else if (line.starts_with("stop"sv)) {
|
||||
return make<StopCommand>(StopCommand::from_string(line));
|
||||
} else if (line.starts_with("id")) {
|
||||
} else if (line.starts_with("id"sv)) {
|
||||
return make<IdCommand>(IdCommand::from_string(line));
|
||||
} else if (line.starts_with("uciok")) {
|
||||
} else if (line.starts_with("uciok"sv)) {
|
||||
return make<UCIOkCommand>(UCIOkCommand::from_string(line));
|
||||
} else if (line.starts_with("readyok")) {
|
||||
} else if (line.starts_with("readyok"sv)) {
|
||||
return make<ReadyOkCommand>(ReadyOkCommand::from_string(line));
|
||||
} else if (line.starts_with("bestmove")) {
|
||||
} else if (line.starts_with("bestmove"sv)) {
|
||||
return make<BestMoveCommand>(BestMoveCommand::from_string(line));
|
||||
} else if (line.starts_with("info")) {
|
||||
} else if (line.starts_with("info"sv)) {
|
||||
return make<InfoCommand>(InfoCommand::from_string(line));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue