Skip to content

Commit 7cac34c

Browse files
SelatShadowNinja
Selat
authored andcommittedMar 12, 2014
Pass arguments by reference
1 parent 2bc2ce3 commit 7cac34c

14 files changed

+49
-49
lines changed
 

‎src/client.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2072,8 +2072,8 @@ void Client::sendChatMessage(const std::wstring &message)
20722072
Send(0, data, true);
20732073
}
20742074

2075-
void Client::sendChangePassword(const std::wstring oldpassword,
2076-
const std::wstring newpassword)
2075+
void Client::sendChangePassword(const std::wstring &oldpassword,
2076+
const std::wstring &newpassword)
20772077
{
20782078
Player *player = m_env.getLocalPlayer();
20792079
if(player == NULL)

‎src/client.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
349349
const std::map<std::string, std::string> &fields);
350350
void sendInventoryAction(InventoryAction *a);
351351
void sendChatMessage(const std::wstring &message);
352-
void sendChangePassword(const std::wstring oldpassword,
353-
const std::wstring newpassword);
352+
void sendChangePassword(const std::wstring &oldpassword,
353+
const std::wstring &newpassword);
354354
void sendDamage(u8 damage);
355355
void sendBreath(u16 breath);
356356
void sendRespawn();

‎src/connection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ void UDPPeer::RunCommandQueues(
11701170
channels[i].queued_commands.push_front(c);
11711171
}
11721172
}
1173-
catch (ItemNotFoundException e) {
1173+
catch (ItemNotFoundException &e) {
11741174
// intentionally empty
11751175
}
11761176
}
@@ -2067,7 +2067,7 @@ void ConnectionReceiveThread::receive()
20672067
m_connection->putEvent(e);
20682068
}
20692069
}
2070-
catch(ProcessedSilentlyException e) {
2070+
catch(ProcessedSilentlyException &e) {
20712071
/* try reading again */
20722072
}
20732073
}

‎src/content_sao.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class ItemSAO : public ServerActiveObject
191191
}
192192

193193
ItemSAO(ServerEnvironment *env, v3f pos,
194-
const std::string itemstring):
194+
const std::string &itemstring):
195195
ServerActiveObject(env, pos),
196196
m_itemstring(itemstring),
197197
m_itemstring_changed(false),
@@ -350,7 +350,7 @@ class ItemSAO : public ServerActiveObject
350350
ItemSAO proto_ItemSAO(NULL, v3f(0,0,0), "");
351351

352352
ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
353-
const std::string itemstring)
353+
const std::string &itemstring)
354354
{
355355
return new ItemSAO(env, pos, itemstring);
356356
}

‎src/content_sao.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2727
#include "object_properties.h"
2828

2929
ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
30-
const std::string itemstring);
30+
const std::string &itemstring);
3131

3232
/*
3333
LuaEntitySAO needs some internals exposed.
@@ -37,7 +37,7 @@ class LuaEntitySAO : public ServerActiveObject
3737
{
3838
public:
3939
LuaEntitySAO(ServerEnvironment *env, v3f pos,
40-
const std::string &name, const std::string &state);
40+
const std::string &name, const std::string &state);
4141
~LuaEntitySAO();
4242
u8 getType() const
4343
{ return ACTIVEOBJECT_TYPE_LUAENTITY; }

‎src/convert_json.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3131
#include "httpfetch.h"
3232
#include "porting.h"
3333

34-
Json::Value fetchJsonValue(const std::string url,
35-
struct curl_slist *chunk) {
34+
Json::Value fetchJsonValue(const std::string &url,
35+
struct curl_slist *chunk) {
3636
#if USE_CURL
3737

3838
HTTPFetchRequest fetchrequest;

‎src/convert_json.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct ModStoreModDetails;
2828
std::vector<ModStoreMod> readModStoreList(Json::Value& modlist);
2929
ModStoreModDetails readModStoreModDetails(Json::Value& details);
3030

31-
Json::Value fetchJsonValue(const std::string url,
32-
struct curl_slist *chunk);
31+
Json::Value fetchJsonValue(const std::string &url,
32+
struct curl_slist *chunk);
3333

3434
#endif

‎src/exceptions.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2727
class BaseException : public std::exception
2828
{
2929
public:
30-
BaseException(const std::string s) throw()
30+
BaseException(const std::string &s) throw()
3131
{
3232
m_s = s;
3333
}
@@ -42,78 +42,78 @@ class BaseException : public std::exception
4242

4343
class AsyncQueuedException : public BaseException {
4444
public:
45-
AsyncQueuedException(std::string s): BaseException(s) {}
45+
AsyncQueuedException(const std::string &s): BaseException(s) {}
4646
};
4747

4848
class NotImplementedException : public BaseException {
4949
public:
50-
NotImplementedException(std::string s): BaseException(s) {}
50+
NotImplementedException(const std::string &s): BaseException(s) {}
5151
};
5252

5353
class AlreadyExistsException : public BaseException {
5454
public:
55-
AlreadyExistsException(std::string s): BaseException(s) {}
55+
AlreadyExistsException(const std::string &s): BaseException(s) {}
5656
};
5757

5858
class VersionMismatchException : public BaseException {
5959
public:
60-
VersionMismatchException(std::string s): BaseException(s) {}
60+
VersionMismatchException(const std::string &s): BaseException(s) {}
6161
};
6262

6363
class FileNotGoodException : public BaseException {
6464
public:
65-
FileNotGoodException(std::string s): BaseException(s) {}
65+
FileNotGoodException(const std::string &s): BaseException(s) {}
6666
};
6767

6868
class SerializationError : public BaseException {
6969
public:
70-
SerializationError(std::string s): BaseException(s) {}
70+
SerializationError(const std::string &s): BaseException(s) {}
7171
};
7272

7373
class LoadError : public BaseException {
7474
public:
75-
LoadError(std::string s): BaseException(s) {}
75+
LoadError(const std::string &s): BaseException(s) {}
7676
};
7777

7878
class ContainerFullException : public BaseException {
7979
public:
80-
ContainerFullException(std::string s): BaseException(s) {}
80+
ContainerFullException(const std::string &s): BaseException(s) {}
8181
};
8282

8383
class SettingNotFoundException : public BaseException {
8484
public:
85-
SettingNotFoundException(std::string s): BaseException(s) {}
85+
SettingNotFoundException(const std::string &s): BaseException(s) {}
8686
};
8787

8888
class InvalidFilenameException : public BaseException {
8989
public:
90-
InvalidFilenameException(std::string s): BaseException(s) {}
90+
InvalidFilenameException(const std::string &s): BaseException(s) {}
9191
};
9292

9393
class ProcessingLimitException : public BaseException {
9494
public:
95-
ProcessingLimitException(std::string s): BaseException(s) {}
95+
ProcessingLimitException(const std::string &s): BaseException(s) {}
9696
};
9797

9898
class CommandLineError : public BaseException {
9999
public:
100-
CommandLineError(std::string s): BaseException(s) {}
100+
CommandLineError(const std::string &s): BaseException(s) {}
101101
};
102102

103103
class ItemNotFoundException : public BaseException {
104104
public:
105-
ItemNotFoundException(std::string s): BaseException(s) {}
105+
ItemNotFoundException(const std::string &s): BaseException(s) {}
106106
};
107107

108108
class ServerError : public BaseException {
109109
public:
110-
ServerError(std::string s): BaseException(s) {}
110+
ServerError(const std::string &s): BaseException(s) {}
111111
};
112112

113113
// Only used on Windows (SEH)
114114
class FatalSystemException : public BaseException {
115115
public:
116-
FatalSystemException(std::string s): BaseException(s) {}
116+
FatalSystemException(const std::string &s): BaseException(s) {}
117117
};
118118

119119
/*
@@ -126,7 +126,7 @@ class InvalidPositionException : public BaseException
126126
InvalidPositionException():
127127
BaseException("Somebody tried to get/set something in a nonexistent position.")
128128
{}
129-
InvalidPositionException(std::string s):
129+
InvalidPositionException(const std::string &s):
130130
BaseException(s)
131131
{}
132132
};

‎src/guiFormSpecMenu.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class GUIFormSpecMenu : public GUIModalMenu
149149
FieldSpec()
150150
{
151151
}
152-
FieldSpec(const std::wstring name, const std::wstring label,
153-
const std::wstring fdeflt, int id) :
152+
FieldSpec(const std::wstring &name, const std::wstring &label,
153+
const std::wstring &fdeflt, int id) :
154154
fname(name),
155155
flabel(label),
156156
fdefault(fdeflt),

‎src/mods.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct ModSpec
6666
bool is_modpack;
6767
// if modpack:
6868
std::map<std::string,ModSpec> modpack_content;
69-
ModSpec(const std::string name_="", const std::string path_=""):
69+
ModSpec(const std::string &name_="", const std::string &path_=""):
7070
name(name_),
7171
path(path_),
7272
depends(),

‎src/script/cpp_api/s_base.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ModNameStorer
4343
private:
4444
lua_State *L;
4545
public:
46-
ModNameStorer(lua_State *L_, const std::string modname):
46+
ModNameStorer(lua_State *L_, const std::string &modname):
4747
L(L_)
4848
{
4949
// Store current modname in registry

‎src/server.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -3046,8 +3046,8 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
30463046
}
30473047
}
30483048

3049-
void Server::SendShowFormspecMessage(u16 peer_id, const std::string formspec,
3050-
const std::string formname)
3049+
void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
3050+
const std::string &formname)
30513051
{
30523052
DSTACK(__FUNCTION_NAME);
30533053

@@ -3871,8 +3871,8 @@ struct SendableMediaAnnouncement
38713871
std::string name;
38723872
std::string sha1_digest;
38733873

3874-
SendableMediaAnnouncement(const std::string name_="",
3875-
const std::string sha1_digest_=""):
3874+
SendableMediaAnnouncement(const std::string &name_="",
3875+
const std::string &sha1_digest_=""):
38763876
name(name_),
38773877
sha1_digest(sha1_digest_)
38783878
{}
@@ -3933,8 +3933,8 @@ struct SendableMedia
39333933
std::string path;
39343934
std::string data;
39353935

3936-
SendableMedia(const std::string &name_="", const std::string path_="",
3937-
const std::string &data_=""):
3936+
SendableMedia(const std::string &name_="", const std::string &path_="",
3937+
const std::string &data_=""):
39383938
name(name_),
39393939
path(path_),
39403940
data(data_)
@@ -4385,7 +4385,7 @@ std::string Server::getBanDescription(const std::string &ip_or_name)
43854385
return m_banmanager->getBanDescription(ip_or_name);
43864386
}
43874387

4388-
void Server::notifyPlayer(const char *name, const std::wstring msg)
4388+
void Server::notifyPlayer(const char *name, const std::wstring &msg)
43894389
{
43904390
Player *player = m_env->getPlayer(name);
43914391
if(!player)
@@ -4498,7 +4498,7 @@ bool Server::overrideDayNightRatio(Player *player, bool do_override,
44984498
return true;
44994499
}
45004500

4501-
void Server::notifyPlayers(const std::wstring msg)
4501+
void Server::notifyPlayers(const std::wstring &msg)
45024502
{
45034503
SendChatMessage(PEER_ID_INEXISTENT,msg);
45044504
}

‎src/server.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ struct MediaInfo
122122
std::string path;
123123
std::string sha1_digest;
124124

125-
MediaInfo(const std::string path_="",
126-
const std::string sha1_digest_=""):
125+
MediaInfo(const std::string &path_="",
126+
const std::string &sha1_digest_=""):
127127
path(path_),
128128
sha1_digest(sha1_digest_)
129129
{
@@ -229,8 +229,8 @@ class Server : public con::PeerHandler, public MapEventReceiver,
229229
void unsetIpBanned(const std::string &ip_or_name);
230230
std::string getBanDescription(const std::string &ip_or_name);
231231

232-
void notifyPlayer(const char *name, const std::wstring msg);
233-
void notifyPlayers(const std::wstring msg);
232+
void notifyPlayer(const char *name, const std::wstring &msg);
233+
void notifyPlayers(const std::wstring &msg);
234234
void spawnParticle(const char *playername,
235235
v3f pos, v3f velocity, v3f acceleration,
236236
float expirationtime, float size,
@@ -357,7 +357,7 @@ class Server : public con::PeerHandler, public MapEventReceiver,
357357
void SendMovePlayer(u16 peer_id);
358358
void SendPlayerPrivileges(u16 peer_id);
359359
void SendPlayerInventoryFormspec(u16 peer_id);
360-
void SendShowFormspecMessage(u16 peer_id, const std::string formspec, const std::string formname);
360+
void SendShowFormspecMessage(u16 peer_id, const std::string &formspec, const std::string &formname);
361361
void SendHUDAdd(u16 peer_id, u32 id, HudElement *form);
362362
void SendHUDRemove(u16 peer_id, u32 id);
363363
void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);

‎src/sound_openal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class OpenALSoundManager: public ISoundManager
391391
}
392392

393393
/* If buffer does not exist, consult the fetcher */
394-
SoundBuffer* getFetchBuffer(const std::string name)
394+
SoundBuffer* getFetchBuffer(const std::string &name)
395395
{
396396
SoundBuffer *buf = getBuffer(name);
397397
if(buf)

0 commit comments

Comments
 (0)
Please sign in to comment.