From 9b1274aba3cad440b925283fe7407954743ade78 Mon Sep 17 00:00:00 2001 From: Antoine Champion Date: Sat, 30 Jan 2021 09:50:04 +0100 Subject: [PATCH] Clean functions returning by const values The codebase contains multiple functions returning by const-value. This patch is a small cleanup making those function returns by value instead, removing the const specifier. closes https://github.com/official-stockfish/Stockfish/pull/3328 No functional change --- AUTHORS | 1 + src/bitboard.cpp | 2 +- src/bitboard.h | 2 +- src/misc.cpp | 4 ++-- src/misc.h | 4 ++-- src/position.cpp | 2 +- src/position.h | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5f21c048..3ef7d1b1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,6 +24,7 @@ Ali AlZhrani (Cooffe) Andrew Grant (AndyGrant) Andrey Neporada (nepal) Andy Duplain +Antoine Champion (antoinechampion) Aram Tumanian (atumanian) Arjun Temurnikar Auguste Pop diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 841aa0b6..8146ce97 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -55,7 +55,7 @@ inline Bitboard safe_destination(Square s, int step) { /// Bitboards::pretty() returns an ASCII representation of a bitboard suitable /// to be printed to standard output. Useful for debugging. -const std::string Bitboards::pretty(Bitboard b) { +std::string Bitboards::pretty(Bitboard b) { std::string s = "+---+---+---+---+---+---+---+---+\n"; diff --git a/src/bitboard.h b/src/bitboard.h index 95591fc4..c9555b6b 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -33,7 +33,7 @@ bool probe(Square wksq, Square wpsq, Square bksq, Color us); namespace Bitboards { void init(); -const std::string pretty(Bitboard b); +std::string pretty(Bitboard b); } diff --git a/src/misc.cpp b/src/misc.cpp index 48e20a39..fe920140 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -138,7 +138,7 @@ public: /// the program was compiled) or "Stockfish ", depending on whether /// Version is empty. -const string engine_info(bool to_uci) { +string engine_info(bool to_uci) { const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"); string month, day, year; @@ -161,7 +161,7 @@ const string engine_info(bool to_uci) { /// compiler_info() returns a string trying to describe the compiler we use -const std::string compiler_info() { +std::string compiler_info() { #define stringify2(x) #x #define stringify(x) stringify2(x) diff --git a/src/misc.h b/src/misc.h index 7b551ade..7eb75bc7 100644 --- a/src/misc.h +++ b/src/misc.h @@ -28,8 +28,8 @@ #include "types.h" -const std::string engine_info(bool to_uci = false); -const std::string compiler_info(); +std::string engine_info(bool to_uci = false); +std::string compiler_info(); void prefetch(void* addr); void start_logger(const std::string& fname); void* std_aligned_alloc(size_t alignment, size_t size); diff --git a/src/position.cpp b/src/position.cpp index 2eb30ca0..8f9b7eee 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -408,7 +408,7 @@ Position& Position::set(const string& code, Color c, StateInfo* si) { /// Position::fen() returns a FEN representation of the position. In case of /// Chess960 the Shredder-FEN notation is used. This is mainly a debugging function. -const string Position::fen() const { +string Position::fen() const { int emptyCnt; std::ostringstream ss; diff --git a/src/position.h b/src/position.h index 3624e29e..e9803756 100644 --- a/src/position.h +++ b/src/position.h @@ -87,7 +87,7 @@ public: // FEN string input/output Position& set(const std::string& fenStr, bool isChess960, StateInfo* si, Thread* th); Position& set(const std::string& code, Color c, StateInfo* si); - const std::string fen() const; + std::string fen() const; // Position representation Bitboard pieces(PieceType pt) const; -- 2.39.2