Pass arguments by reference

This commit is contained in:
Selat 2014-02-27 23:12:59 +03:00 committed by ShadowNinja
parent 2bc2ce3bd1
commit 7cac34c807
14 changed files with 49 additions and 49 deletions

@ -2072,8 +2072,8 @@ void Client::sendChatMessage(const std::wstring &message)
Send(0, data, true); Send(0, data, true);
} }
void Client::sendChangePassword(const std::wstring oldpassword, void Client::sendChangePassword(const std::wstring &oldpassword,
const std::wstring newpassword) const std::wstring &newpassword)
{ {
Player *player = m_env.getLocalPlayer(); Player *player = m_env.getLocalPlayer();
if(player == NULL) if(player == NULL)

@ -349,8 +349,8 @@ public:
const std::map<std::string, std::string> &fields); const std::map<std::string, std::string> &fields);
void sendInventoryAction(InventoryAction *a); void sendInventoryAction(InventoryAction *a);
void sendChatMessage(const std::wstring &message); void sendChatMessage(const std::wstring &message);
void sendChangePassword(const std::wstring oldpassword, void sendChangePassword(const std::wstring &oldpassword,
const std::wstring newpassword); const std::wstring &newpassword);
void sendDamage(u8 damage); void sendDamage(u8 damage);
void sendBreath(u16 breath); void sendBreath(u16 breath);
void sendRespawn(); void sendRespawn();

@ -1170,7 +1170,7 @@ void UDPPeer::RunCommandQueues(
channels[i].queued_commands.push_front(c); channels[i].queued_commands.push_front(c);
} }
} }
catch (ItemNotFoundException e) { catch (ItemNotFoundException &e) {
// intentionally empty // intentionally empty
} }
} }
@ -2067,7 +2067,7 @@ void ConnectionReceiveThread::receive()
m_connection->putEvent(e); m_connection->putEvent(e);
} }
} }
catch(ProcessedSilentlyException e) { catch(ProcessedSilentlyException &e) {
/* try reading again */ /* try reading again */
} }
} }

@ -191,7 +191,7 @@ public:
} }
ItemSAO(ServerEnvironment *env, v3f pos, ItemSAO(ServerEnvironment *env, v3f pos,
const std::string itemstring): const std::string &itemstring):
ServerActiveObject(env, pos), ServerActiveObject(env, pos),
m_itemstring(itemstring), m_itemstring(itemstring),
m_itemstring_changed(false), m_itemstring_changed(false),
@ -350,7 +350,7 @@ private:
ItemSAO proto_ItemSAO(NULL, v3f(0,0,0), ""); ItemSAO proto_ItemSAO(NULL, v3f(0,0,0), "");
ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos, ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
const std::string itemstring) const std::string &itemstring)
{ {
return new ItemSAO(env, pos, itemstring); return new ItemSAO(env, pos, itemstring);
} }

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "object_properties.h" #include "object_properties.h"
ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos, ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
const std::string itemstring); const std::string &itemstring);
/* /*
LuaEntitySAO needs some internals exposed. LuaEntitySAO needs some internals exposed.
@ -37,7 +37,7 @@ class LuaEntitySAO : public ServerActiveObject
{ {
public: public:
LuaEntitySAO(ServerEnvironment *env, v3f pos, LuaEntitySAO(ServerEnvironment *env, v3f pos,
const std::string &name, const std::string &state); const std::string &name, const std::string &state);
~LuaEntitySAO(); ~LuaEntitySAO();
u8 getType() const u8 getType() const
{ return ACTIVEOBJECT_TYPE_LUAENTITY; } { return ACTIVEOBJECT_TYPE_LUAENTITY; }

@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "httpfetch.h" #include "httpfetch.h"
#include "porting.h" #include "porting.h"
Json::Value fetchJsonValue(const std::string url, Json::Value fetchJsonValue(const std::string &url,
struct curl_slist *chunk) { struct curl_slist *chunk) {
#if USE_CURL #if USE_CURL
HTTPFetchRequest fetchrequest; HTTPFetchRequest fetchrequest;

@ -28,7 +28,7 @@ struct ModStoreModDetails;
std::vector<ModStoreMod> readModStoreList(Json::Value& modlist); std::vector<ModStoreMod> readModStoreList(Json::Value& modlist);
ModStoreModDetails readModStoreModDetails(Json::Value& details); ModStoreModDetails readModStoreModDetails(Json::Value& details);
Json::Value fetchJsonValue(const std::string url, Json::Value fetchJsonValue(const std::string &url,
struct curl_slist *chunk); struct curl_slist *chunk);
#endif #endif

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class BaseException : public std::exception class BaseException : public std::exception
{ {
public: public:
BaseException(const std::string s) throw() BaseException(const std::string &s) throw()
{ {
m_s = s; m_s = s;
} }
@ -42,78 +42,78 @@ protected:
class AsyncQueuedException : public BaseException { class AsyncQueuedException : public BaseException {
public: public:
AsyncQueuedException(std::string s): BaseException(s) {} AsyncQueuedException(const std::string &s): BaseException(s) {}
}; };
class NotImplementedException : public BaseException { class NotImplementedException : public BaseException {
public: public:
NotImplementedException(std::string s): BaseException(s) {} NotImplementedException(const std::string &s): BaseException(s) {}
}; };
class AlreadyExistsException : public BaseException { class AlreadyExistsException : public BaseException {
public: public:
AlreadyExistsException(std::string s): BaseException(s) {} AlreadyExistsException(const std::string &s): BaseException(s) {}
}; };
class VersionMismatchException : public BaseException { class VersionMismatchException : public BaseException {
public: public:
VersionMismatchException(std::string s): BaseException(s) {} VersionMismatchException(const std::string &s): BaseException(s) {}
}; };
class FileNotGoodException : public BaseException { class FileNotGoodException : public BaseException {
public: public:
FileNotGoodException(std::string s): BaseException(s) {} FileNotGoodException(const std::string &s): BaseException(s) {}
}; };
class SerializationError : public BaseException { class SerializationError : public BaseException {
public: public:
SerializationError(std::string s): BaseException(s) {} SerializationError(const std::string &s): BaseException(s) {}
}; };
class LoadError : public BaseException { class LoadError : public BaseException {
public: public:
LoadError(std::string s): BaseException(s) {} LoadError(const std::string &s): BaseException(s) {}
}; };
class ContainerFullException : public BaseException { class ContainerFullException : public BaseException {
public: public:
ContainerFullException(std::string s): BaseException(s) {} ContainerFullException(const std::string &s): BaseException(s) {}
}; };
class SettingNotFoundException : public BaseException { class SettingNotFoundException : public BaseException {
public: public:
SettingNotFoundException(std::string s): BaseException(s) {} SettingNotFoundException(const std::string &s): BaseException(s) {}
}; };
class InvalidFilenameException : public BaseException { class InvalidFilenameException : public BaseException {
public: public:
InvalidFilenameException(std::string s): BaseException(s) {} InvalidFilenameException(const std::string &s): BaseException(s) {}
}; };
class ProcessingLimitException : public BaseException { class ProcessingLimitException : public BaseException {
public: public:
ProcessingLimitException(std::string s): BaseException(s) {} ProcessingLimitException(const std::string &s): BaseException(s) {}
}; };
class CommandLineError : public BaseException { class CommandLineError : public BaseException {
public: public:
CommandLineError(std::string s): BaseException(s) {} CommandLineError(const std::string &s): BaseException(s) {}
}; };
class ItemNotFoundException : public BaseException { class ItemNotFoundException : public BaseException {
public: public:
ItemNotFoundException(std::string s): BaseException(s) {} ItemNotFoundException(const std::string &s): BaseException(s) {}
}; };
class ServerError : public BaseException { class ServerError : public BaseException {
public: public:
ServerError(std::string s): BaseException(s) {} ServerError(const std::string &s): BaseException(s) {}
}; };
// Only used on Windows (SEH) // Only used on Windows (SEH)
class FatalSystemException : public BaseException { class FatalSystemException : public BaseException {
public: public:
FatalSystemException(std::string s): BaseException(s) {} FatalSystemException(const std::string &s): BaseException(s) {}
}; };
/* /*
@ -126,7 +126,7 @@ public:
InvalidPositionException(): InvalidPositionException():
BaseException("Somebody tried to get/set something in a nonexistent position.") BaseException("Somebody tried to get/set something in a nonexistent position.")
{} {}
InvalidPositionException(std::string s): InvalidPositionException(const std::string &s):
BaseException(s) BaseException(s)
{} {}
}; };

@ -149,8 +149,8 @@ class GUIFormSpecMenu : public GUIModalMenu
FieldSpec() FieldSpec()
{ {
} }
FieldSpec(const std::wstring name, const std::wstring label, FieldSpec(const std::wstring &name, const std::wstring &label,
const std::wstring fdeflt, int id) : const std::wstring &fdeflt, int id) :
fname(name), fname(name),
flabel(label), flabel(label),
fdefault(fdeflt), fdefault(fdeflt),

@ -66,7 +66,7 @@ struct ModSpec
bool is_modpack; bool is_modpack;
// if modpack: // if modpack:
std::map<std::string,ModSpec> modpack_content; std::map<std::string,ModSpec> modpack_content;
ModSpec(const std::string name_="", const std::string path_=""): ModSpec(const std::string &name_="", const std::string &path_=""):
name(name_), name(name_),
path(path_), path(path_),
depends(), depends(),

@ -43,7 +43,7 @@ class ModNameStorer
private: private:
lua_State *L; lua_State *L;
public: public:
ModNameStorer(lua_State *L_, const std::string modname): ModNameStorer(lua_State *L_, const std::string &modname):
L(L_) L(L_)
{ {
// Store current modname in registry // Store current modname in registry

@ -3046,8 +3046,8 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
} }
} }
void Server::SendShowFormspecMessage(u16 peer_id, const std::string formspec, void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
const std::string formname) const std::string &formname)
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
@ -3871,8 +3871,8 @@ struct SendableMediaAnnouncement
std::string name; std::string name;
std::string sha1_digest; std::string sha1_digest;
SendableMediaAnnouncement(const std::string name_="", SendableMediaAnnouncement(const std::string &name_="",
const std::string sha1_digest_=""): const std::string &sha1_digest_=""):
name(name_), name(name_),
sha1_digest(sha1_digest_) sha1_digest(sha1_digest_)
{} {}
@ -3933,8 +3933,8 @@ struct SendableMedia
std::string path; std::string path;
std::string data; std::string data;
SendableMedia(const std::string &name_="", const std::string path_="", SendableMedia(const std::string &name_="", const std::string &path_="",
const std::string &data_=""): const std::string &data_=""):
name(name_), name(name_),
path(path_), path(path_),
data(data_) data(data_)
@ -4385,7 +4385,7 @@ std::string Server::getBanDescription(const std::string &ip_or_name)
return m_banmanager->getBanDescription(ip_or_name); return m_banmanager->getBanDescription(ip_or_name);
} }
void Server::notifyPlayer(const char *name, const std::wstring msg) void Server::notifyPlayer(const char *name, const std::wstring &msg)
{ {
Player *player = m_env->getPlayer(name); Player *player = m_env->getPlayer(name);
if(!player) if(!player)
@ -4498,7 +4498,7 @@ bool Server::overrideDayNightRatio(Player *player, bool do_override,
return true; return true;
} }
void Server::notifyPlayers(const std::wstring msg) void Server::notifyPlayers(const std::wstring &msg)
{ {
SendChatMessage(PEER_ID_INEXISTENT,msg); SendChatMessage(PEER_ID_INEXISTENT,msg);
} }

@ -122,8 +122,8 @@ struct MediaInfo
std::string path; std::string path;
std::string sha1_digest; std::string sha1_digest;
MediaInfo(const std::string path_="", MediaInfo(const std::string &path_="",
const std::string sha1_digest_=""): const std::string &sha1_digest_=""):
path(path_), path(path_),
sha1_digest(sha1_digest_) sha1_digest(sha1_digest_)
{ {
@ -229,8 +229,8 @@ public:
void unsetIpBanned(const std::string &ip_or_name); void unsetIpBanned(const std::string &ip_or_name);
std::string getBanDescription(const std::string &ip_or_name); std::string getBanDescription(const std::string &ip_or_name);
void notifyPlayer(const char *name, const std::wstring msg); void notifyPlayer(const char *name, const std::wstring &msg);
void notifyPlayers(const std::wstring msg); void notifyPlayers(const std::wstring &msg);
void spawnParticle(const char *playername, void spawnParticle(const char *playername,
v3f pos, v3f velocity, v3f acceleration, v3f pos, v3f velocity, v3f acceleration,
float expirationtime, float size, float expirationtime, float size,
@ -357,7 +357,7 @@ private:
void SendMovePlayer(u16 peer_id); void SendMovePlayer(u16 peer_id);
void SendPlayerPrivileges(u16 peer_id); void SendPlayerPrivileges(u16 peer_id);
void SendPlayerInventoryFormspec(u16 peer_id); void SendPlayerInventoryFormspec(u16 peer_id);
void SendShowFormspecMessage(u16 peer_id, const std::string formspec, const std::string formname); void SendShowFormspecMessage(u16 peer_id, const std::string &formspec, const std::string &formname);
void SendHUDAdd(u16 peer_id, u32 id, HudElement *form); void SendHUDAdd(u16 peer_id, u32 id, HudElement *form);
void SendHUDRemove(u16 peer_id, u32 id); void SendHUDRemove(u16 peer_id, u32 id);
void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value); void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);

@ -391,7 +391,7 @@ public:
} }
/* If buffer does not exist, consult the fetcher */ /* If buffer does not exist, consult the fetcher */
SoundBuffer* getFetchBuffer(const std::string name) SoundBuffer* getFetchBuffer(const std::string &name)
{ {
SoundBuffer *buf = getBuffer(name); SoundBuffer *buf = getBuffer(name);
if(buf) if(buf)