mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 12:07:43 +00:00
Replace some std::string occurrences with std::string_view
std::string_view is more lightweight than std::string. Furthermore, std::string_view variables can be declared constexpr. closes https://github.com/official-stockfish/Stockfish/pull/4328 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
5a88c5bb9b
commit
e9e7a7b83f
+5
-4
@@ -41,12 +41,13 @@ typedef WORD(*fun5_t)();
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
#include <stdlib.h>
|
||||
@@ -68,7 +69,7 @@ namespace Stockfish {
|
||||
namespace {
|
||||
|
||||
/// Version number or dev.
|
||||
const string version = "dev";
|
||||
constexpr string_view version = "dev";
|
||||
|
||||
/// Our fancy logging facility. The trick here is to replace cin.rdbuf() and
|
||||
/// cout.rdbuf() with two Tie objects that tie cin and cout to a file stream. We
|
||||
@@ -151,13 +152,13 @@ string engine_info(bool to_uci) {
|
||||
stringstream ss;
|
||||
ss << "Stockfish " << version << setfill('0');
|
||||
|
||||
if (version == "dev")
|
||||
if constexpr (version == "dev")
|
||||
{
|
||||
ss << "-";
|
||||
#ifdef GIT_DATE
|
||||
ss << GIT_DATE;
|
||||
#else
|
||||
const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec");
|
||||
constexpr string_view months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec");
|
||||
string month, day, year;
|
||||
stringstream date(__DATE__); // From compiler, format is "Sep 21 2008"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user