Changeset - r26817:1d282e59fc7b
[Not reviewed]
master
0 3 0
Rubidium - 22 months ago 2023-01-28 12:02:05
rubidium@openttd.org
Codechange: pass large objects by reference instead of value

Especially when they get passed on directly to the next function or via a
constructor into an instance variable
3 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/network/core/tcp.h
Show inline comments
 
@@ -115,7 +115,7 @@ private:
 

	
 
public:
 
	TCPConnecter() {};
 
	TCPConnecter(const std::string &connection_string, uint16 default_port, NetworkAddress bind_address = {}, int family = AF_UNSPEC);
 
	TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address = {}, int family = AF_UNSPEC);
 
	virtual ~TCPConnecter();
 

	
 
	/**
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -29,7 +29,7 @@ static std::vector<TCPConnecter *> _tcp_
 
 * @param default_port If not indicated in connection_string, what port to use.
 
 * @param bind_address The local bind address to use. Defaults to letting the OS find one.
 
 */
 
TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_port, NetworkAddress bind_address, int family) :
 
TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address, int family) :
 
	bind_address(bind_address),
 
	family(family)
 
{
src/settings_internal.h
Show inline comments
 
@@ -70,7 +70,7 @@ struct IniItem;
 

	
 
/** Properties of config file settings. */
 
struct SettingDesc {
 
	SettingDesc(SaveLoad save, SettingFlag flags, bool startup) :
 
	SettingDesc(const SaveLoad &save, SettingFlag flags, bool startup) :
 
		flags(flags), startup(startup), save(save) {}
 
	virtual ~SettingDesc() {}
 

	
 
@@ -149,7 +149,7 @@ struct IntSettingDesc : SettingDesc {
 
	 */
 
	typedef void PostChangeCallback(int32 value);
 

	
 
	IntSettingDesc(SaveLoad save, SettingFlag flags, bool startup, int32 def,
 
	IntSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32 def,
 
			int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val,
 
			SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback) :
 
		SettingDesc(save, flags, startup), def(def), min(min), max(max), interval(interval),
 
@@ -191,7 +191,7 @@ private:
 

	
 
/** Boolean setting. */
 
struct BoolSettingDesc : IntSettingDesc {
 
	BoolSettingDesc(SaveLoad save, SettingFlag flags, bool startup, bool def,
 
	BoolSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, bool def,
 
			StringID str, StringID str_help, StringID str_val, SettingCategory cat,
 
			PreChangeCheck pre_check, PostChangeCallback post_callback) :
 
		IntSettingDesc(save, flags, startup, def, 0, 1, 0, str, str_help, str_val, cat,
 
@@ -207,7 +207,7 @@ struct BoolSettingDesc : IntSettingDesc 
 
struct OneOfManySettingDesc : IntSettingDesc {
 
	typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error
 

	
 
	OneOfManySettingDesc(SaveLoad save, SettingFlag flags, bool startup, int32 def,
 
	OneOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32 def,
 
			int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
 
			PreChangeCheck pre_check, PostChangeCallback post_callback,
 
			std::initializer_list<const char *> many, OnConvert *many_cnvt) :
 
@@ -231,7 +231,7 @@ struct OneOfManySettingDesc : IntSetting
 

	
 
/** Many of many setting. */
 
struct ManyOfManySettingDesc : OneOfManySettingDesc {
 
	ManyOfManySettingDesc(SaveLoad save, SettingFlag flags, bool startup,
 
	ManyOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup,
 
		int32 def, StringID str, StringID str_help, StringID str_val, SettingCategory cat,
 
		PreChangeCheck pre_check, PostChangeCallback post_callback,
 
		std::initializer_list<const char *> many, OnConvert *many_cnvt) :
 
@@ -260,7 +260,7 @@ struct StringSettingDesc : SettingDesc {
 
	 */
 
	typedef void PostChangeCallback(const std::string &value);
 

	
 
	StringSettingDesc(SaveLoad save, SettingFlag flags, bool startup, const char *def,
 
	StringSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, const char *def,
 
			uint32 max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) :
 
		SettingDesc(save, flags, startup), def(def == nullptr ? "" : def), max_length(max_length),
 
			pre_check(pre_check), post_callback(post_callback) {}
 
@@ -286,7 +286,7 @@ private:
 

	
 
/** List/array settings. */
 
struct ListSettingDesc : SettingDesc {
 
	ListSettingDesc(SaveLoad save, SettingFlag flags, bool startup, const char *def) :
 
	ListSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, const char *def) :
 
		SettingDesc(save, flags, startup), def(def) {}
 
	virtual ~ListSettingDesc() {}
 

	
 
@@ -299,7 +299,7 @@ struct ListSettingDesc : SettingDesc {
 

	
 
/** Placeholder for settings that have been removed, but might still linger in the savegame. */
 
struct NullSettingDesc : SettingDesc {
 
	NullSettingDesc(SaveLoad save) :
 
	NullSettingDesc(const SaveLoad &save) :
 
		SettingDesc(save, SF_NOT_IN_CONFIG, false) {}
 
	virtual ~NullSettingDesc() {}
 

	
0 comments (0 inline, 0 general)