1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 18:32:35 +01:00

Codechange: use std::string_view over const char *

This commit is contained in:
Rubidium
2025-04-27 17:17:05 +02:00
committed by rubidium42
parent c7056866a3
commit 29ceaf0a84
12 changed files with 27 additions and 27 deletions

View File

@@ -842,9 +842,9 @@ void TextfileWindow::LoadText(std::string_view buf)
* @param filename The filename of the content to look for.
* @return The path to the textfile, \c nullptr otherwise.
*/
std::optional<std::string> GetTextfile(TextfileType type, Subdirectory dir, const std::string &filename)
std::optional<std::string> GetTextfile(TextfileType type, Subdirectory dir, std::string_view filename)
{
static const char * const prefixes[] = {
static const std::string_view prefixes[] = {
"readme",
"changelog",
"license",
@@ -861,7 +861,7 @@ std::optional<std::string> GetTextfile(TextfileType type, Subdirectory dir, cons
auto slash = filename.find_last_of(PATHSEPCHAR);
if (slash == std::string::npos) return std::nullopt;
std::string_view base_path(filename.data(), slash + 1);
std::string_view base_path = filename.substr(0, slash + 1);
static const std::initializer_list<std::string_view> extensions{
"txt",