mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Codechange: Redundant use of char * and c_str(). (#11454)
This commit is contained in:
parent
938c8339d2
commit
1071acb483
@ -106,19 +106,19 @@ struct BaseSet {
|
||||
* @param isocode the isocode to search for
|
||||
* @return the description
|
||||
*/
|
||||
const char *GetDescription(const std::string &isocode) const
|
||||
const std::string &GetDescription(const std::string &isocode) const
|
||||
{
|
||||
if (!isocode.empty()) {
|
||||
/* First the full ISO code */
|
||||
auto desc = this->description.find(isocode);
|
||||
if (desc != this->description.end()) return desc->second.c_str();
|
||||
if (desc != this->description.end()) return desc->second;
|
||||
|
||||
/* Then the first two characters */
|
||||
desc = this->description.find(isocode.substr(0, 2));
|
||||
if (desc != this->description.end()) return desc->second.c_str();
|
||||
if (desc != this->description.end()) return desc->second;
|
||||
}
|
||||
/* Then fall back */
|
||||
return this->description.at(std::string{}).c_str();
|
||||
return this->description.at(std::string{});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,11 +125,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
*/
|
||||
virtual void UpdateVirtCoord() = 0;
|
||||
|
||||
inline const char *GetCachedName() const
|
||||
inline const std::string &GetCachedName() const
|
||||
{
|
||||
if (!this->name.empty()) return this->name.c_str();
|
||||
if (!this->name.empty()) return this->name;
|
||||
if (this->cached_name.empty()) this->FillCachedName();
|
||||
return this->cached_name.c_str();
|
||||
return this->cached_name;
|
||||
}
|
||||
|
||||
virtual void MoveSign(TileIndex new_xy)
|
||||
|
@ -326,7 +326,7 @@ void LoadCoreTextFont(FontSize fs)
|
||||
path.reset(CFStringCreateWithCString(kCFAllocatorDefault, settings->font.c_str(), kCFStringEncodingUTF8));
|
||||
} else {
|
||||
/* Scan the search-paths to see if it can be found. */
|
||||
std::string full_font = FioFindFullPath(BASE_DIR, settings->font.c_str());
|
||||
std::string full_font = FioFindFullPath(BASE_DIR, settings->font);
|
||||
if (!full_font.empty()) {
|
||||
path.reset(CFStringCreateWithCString(kCFAllocatorDefault, full_font.c_str(), kCFStringEncodingUTF8));
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ ScriptStorage::~ScriptStorage()
|
||||
static void PrintFunc(bool error_msg, const std::string &message)
|
||||
{
|
||||
/* Convert to OpenTTD internal capable string */
|
||||
ScriptController::Print(error_msg, message.c_str());
|
||||
ScriptController::Print(error_msg, message);
|
||||
}
|
||||
|
||||
ScriptInstance::ScriptInstance(const char *APIName) :
|
||||
|
@ -1552,7 +1552,7 @@ void DeleteGRFPresetFromConfig(const char *config_name)
|
||||
section += config_name;
|
||||
|
||||
ConfigIniFile ini(_config_file);
|
||||
ini.RemoveGroup(section.c_str());
|
||||
ini.RemoveGroup(section);
|
||||
ini.SaveToDisk(_config_file);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ struct FileStringReader : StringReader {
|
||||
* @param translation Are we reading a translation?
|
||||
*/
|
||||
FileStringReader(StringData &data, const std::filesystem::path &file, bool master, bool translation) :
|
||||
StringReader(data, file.generic_string().c_str(), master, translation)
|
||||
StringReader(data, file.generic_string(), master, translation)
|
||||
{
|
||||
this->input_stream.open(file, std::ifstream::binary);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user