Changeset - r28129:82468bbffe23
[Not reviewed]
master
0 6 0
Peter Nelson - 6 months ago 2023-11-10 00:17:36
peter1138@openttd.org
Codechange: Redundant use of char * and c_str(). (#11454)
6 files changed with 11 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/base_media_base.h
Show inline comments
 
@@ -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{});
 
	}
 

	
 
	/**
src/base_station_base.h
Show inline comments
 
@@ -125,11 +125,11 @@ struct BaseStation : StationPool::PoolIt
 
	 */
 
	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)
src/os/macosx/font_osx.cpp
Show inline comments
 
@@ -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));
 
			}
src/script/script_instance.cpp
Show inline comments
 
@@ -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) :
src/settings.cpp
Show inline comments
 
@@ -1552,7 +1552,7 @@ void DeleteGRFPresetFromConfig(const cha
 
	section += config_name;
 

	
 
	ConfigIniFile ini(_config_file);
 
	ini.RemoveGroup(section.c_str());
 
	ini.RemoveGroup(section);
 
	ini.SaveToDisk(_config_file);
 
}
 

	
src/strgen/strgen.cpp
Show inline comments
 
@@ -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);
 
	}
0 comments (0 inline, 0 general)