1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 02:12:37 +01:00

Codechange: use const for std::string_view where appropriate

This commit is contained in:
Rubidium
2025-04-29 07:10:48 +02:00
committed by rubidium42
parent 78250c3bba
commit af25eecc15
34 changed files with 87 additions and 87 deletions

View File

@@ -100,7 +100,7 @@ void FileList::BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperati
* or a numbered entry into the filename list.
* @return The information on the file, or \c nullptr if the file is not available.
*/
const FiosItem *FileList::FindItem(const std::string_view file)
const FiosItem *FileList::FindItem(std::string_view file)
{
for (const auto &it : *this) {
const FiosItem *item = ⁢
@@ -240,7 +240,7 @@ bool FiosDelete(std::string_view name)
return FioRemove(FiosMakeSavegameName(name));
}
typedef std::tuple<FiosType, std::string> FiosGetTypeAndNameProc(SaveLoadOperation fop, const std::string &filename, const std::string_view ext);
typedef std::tuple<FiosType, std::string> FiosGetTypeAndNameProc(SaveLoadOperation fop, const std::string &filename, std::string_view ext);
/**
* Scanner to scan for a particular type of FIOS file.
@@ -398,7 +398,7 @@ static std::string GetFileTitle(const std::string &file, Subdirectory subdir)
* @see FiosGetFileList
* @see FiosGetSavegameList
*/
std::tuple<FiosType, std::string> FiosGetSavegameListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext)
std::tuple<FiosType, std::string> FiosGetSavegameListCallback(SaveLoadOperation fop, const std::string &file, std::string_view ext)
{
/* Show savegame files
* .SAV OpenTTD saved game
@@ -447,7 +447,7 @@ void FiosGetSavegameList(SaveLoadOperation fop, bool show_dirs, FileList &file_l
* @see FiosGetFileList
* @see FiosGetScenarioList
*/
std::tuple<FiosType, std::string> FiosGetScenarioListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext)
std::tuple<FiosType, std::string> FiosGetScenarioListCallback(SaveLoadOperation fop, const std::string &file, std::string_view ext)
{
/* Show scenario files
* .SCN OpenTTD style scenario file
@@ -488,7 +488,7 @@ void FiosGetScenarioList(SaveLoadOperation fop, bool show_dirs, FileList &file_l
FiosGetFileList(fop, show_dirs, &FiosGetScenarioListCallback, subdir, file_list);
}
std::tuple<FiosType, std::string> FiosGetHeightmapListCallback(SaveLoadOperation, const std::string &file, const std::string_view ext)
std::tuple<FiosType, std::string> FiosGetHeightmapListCallback(SaveLoadOperation, const std::string &file, std::string_view ext)
{
/* Show heightmap files
* .PNG PNG Based heightmap files
@@ -553,7 +553,7 @@ void FiosGetHeightmapList(SaveLoadOperation fop, bool show_dirs, FileList &file_
* @param file Name of the file to check.
* @return a FIOS_TYPE_JSON type of the found file, FIOS_TYPE_INVALID if not a valid JSON file, and the title of the file (if any).
*/
static std::tuple<FiosType, std::string> FiosGetTownDataListCallback(SaveLoadOperation fop, const std::string &file, const std::string_view ext)
static std::tuple<FiosType, std::string> FiosGetTownDataListCallback(SaveLoadOperation fop, const std::string &file, std::string_view ext)
{
if (fop == SLO_LOAD) {
if (StrEqualsIgnoreCase(ext, ".json")) {
@@ -715,7 +715,7 @@ FiosNumberedSaveName::FiosNumberedSaveName(const std::string &prefix) : prefix(p
static std::string _prefix; ///< Static as the lambda needs access to it.
/* Callback for FiosFileScanner. */
static FiosGetTypeAndNameProc *proc = [](SaveLoadOperation, const std::string &file, const std::string_view ext) {
static FiosGetTypeAndNameProc *proc = [](SaveLoadOperation, const std::string &file, std::string_view ext) {
if (StrEqualsIgnoreCase(ext, ".sav") && file.starts_with(_prefix)) return std::tuple(FIOS_TYPE_FILE, std::string{});
return std::tuple(FIOS_TYPE_INVALID, std::string{});
};