Pass arguments by reference
authorSelat <LongExampleTestName@gmail.com>
Thu, 27 Feb 2014 20:12:59 +0000 (23:12 +0300)
committerShadowNinja <shadowninja@minetest.net>
Wed, 12 Mar 2014 21:34:48 +0000 (17:34 -0400)
14 files changed:
src/client.cpp
src/client.h
src/connection.cpp
src/content_sao.cpp
src/content_sao.h
src/convert_json.cpp
src/convert_json.h
src/exceptions.h
src/guiFormSpecMenu.h
src/mods.h
src/script/cpp_api/s_base.cpp
src/server.cpp
src/server.h
src/sound_openal.cpp

index 4d6c0cb9907337c6dc56d95e4935d64636640fa4..654052ac0a40076aba3c4cdba3facc255e9dbfd3 100644 (file)
@@ -2072,8 +2072,8 @@ void Client::sendChatMessage(const std::wstring &message)
        Send(0, data, true);
 }
 
-void Client::sendChangePassword(const std::wstring oldpassword,
-               const std::wstring newpassword)
+void Client::sendChangePassword(const std::wstring &oldpassword,
+                                const std::wstring &newpassword)
 {
        Player *player = m_env.getLocalPlayer();
        if(player == NULL)
index 01cd3a01c6904dbdcf2d2ebed09a26026696980a..f2e1b86d7bbd133a731aa76bc2ea9216853da586 100644 (file)
@@ -349,8 +349,8 @@ public:
                        const std::map<std::string, std::string> &fields);
        void sendInventoryAction(InventoryAction *a);
        void sendChatMessage(const std::wstring &message);
-       void sendChangePassword(const std::wstring oldpassword,
-                       const std::wstring newpassword);
+       void sendChangePassword(const std::wstring &oldpassword,
+                               const std::wstring &newpassword);
        void sendDamage(u8 damage);
        void sendBreath(u16 breath);
        void sendRespawn();
index f8c68ed2ec7b59660f1321fc38f3f7735e2d73e7..8a23f67c3e48b8845267056b83fc420f8ac38754 100644 (file)
@@ -1170,7 +1170,7 @@ void UDPPeer::RunCommandQueues(
                                        channels[i].queued_commands.push_front(c);
                                }
                        }
-                       catch (ItemNotFoundException e) {
+                       catch (ItemNotFoundException &e) {
                                // intentionally empty
                        }
                }
@@ -2067,7 +2067,7 @@ void ConnectionReceiveThread::receive()
                                                m_connection->putEvent(e);
                                        }
                                }
-                               catch(ProcessedSilentlyException e) {
+                               catch(ProcessedSilentlyException &e) {
                                        /* try reading again */
                                }
                        }
index 52b741365cfa18c16606d3d3a4cdb85b4b3389d7..095c6b5bf26c969f064e752fe815aa3d272df2aa 100644 (file)
@@ -191,7 +191,7 @@ public:
        }
 
        ItemSAO(ServerEnvironment *env, v3f pos,
-                       const std::string itemstring):
+                       const std::string &itemstring):
                ServerActiveObject(env, pos),
                m_itemstring(itemstring),
                m_itemstring_changed(false),
@@ -350,7 +350,7 @@ private:
 ItemSAO proto_ItemSAO(NULL, v3f(0,0,0), "");
 
 ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
-               const std::string itemstring)
+                                  const std::string &itemstring)
 {
        return new ItemSAO(env, pos, itemstring);
 }
index 1be620f299b3845749b2a9a01ac7d685b16eb086..63e8ef4601f3234a3c0170d67acac704dfa74337 100644 (file)
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "object_properties.h"
 
 ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
-               const std::string itemstring);
+                                  const std::string &itemstring);
 
 /*
        LuaEntitySAO needs some internals exposed.
@@ -37,7 +37,7 @@ class LuaEntitySAO : public ServerActiveObject
 {
 public:
        LuaEntitySAO(ServerEnvironment *env, v3f pos,
-                       const std::string &name, const std::string &state);
+                    const std::string &name, const std::string &state);
        ~LuaEntitySAO();
        u8 getType() const
        { return ACTIVEOBJECT_TYPE_LUAENTITY; }
index c8e57aaf78c58687c61388748a4f117a48d53e8d..6f227e7967501818789185036e7082403d81b016 100644 (file)
@@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "httpfetch.h"
 #include "porting.h"
 
-Json::Value                 fetchJsonValue(const std::string url,
-                                                                                                       struct curl_slist *chunk) {
+Json::Value                 fetchJsonValue(const std::string &url,
+                                           struct curl_slist *chunk) {
 #if USE_CURL
 
        HTTPFetchRequest fetchrequest;
index 3fa9903b1e617d9506b787a997145e0b20923127..ea9bafb799a4afcd6507d81d889dc07b474f955f 100644 (file)
@@ -28,7 +28,7 @@ struct ModStoreModDetails;
 std::vector<ModStoreMod>    readModStoreList(Json::Value& modlist);
 ModStoreModDetails          readModStoreModDetails(Json::Value& details);
 
-Json::Value                 fetchJsonValue(const std::string url,
-                                                                                                       struct curl_slist *chunk);
+Json::Value                 fetchJsonValue(const std::string &url,
+                                           struct curl_slist *chunk);
 
 #endif
index 6fb97f3ed3758a52db40d5905519b229b9339ede..970c68e4027450149d476b829e754dea8dedd01f 100644 (file)
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class BaseException : public std::exception
 {
 public:
-       BaseException(const std::string s) throw()
+       BaseException(const std::string &s) throw()
        {
                m_s = s;
        }
@@ -42,78 +42,78 @@ protected:
 
 class AsyncQueuedException : public BaseException {
 public:
-       AsyncQueuedException(std::string s): BaseException(s) {}
+       AsyncQueuedException(const std::string &s): BaseException(s) {}
 };
 
 class NotImplementedException : public BaseException {
 public:
-       NotImplementedException(std::string s): BaseException(s) {}
+       NotImplementedException(const std::string &s): BaseException(s) {}
 };
 
 class AlreadyExistsException : public BaseException {
 public:
-       AlreadyExistsException(std::string s): BaseException(s) {}
+       AlreadyExistsException(const std::string &s): BaseException(s) {}
 };
 
 class VersionMismatchException : public BaseException {
 public:
-       VersionMismatchException(std::string s): BaseException(s) {}
+       VersionMismatchException(const std::string &s): BaseException(s) {}
 };
 
 class FileNotGoodException : public BaseException {
 public:
-       FileNotGoodException(std::string s): BaseException(s) {}
+       FileNotGoodException(const std::string &s): BaseException(s) {}
 };
 
 class SerializationError : public BaseException {
 public:
-       SerializationError(std::string s): BaseException(s) {}
+       SerializationError(const std::string &s): BaseException(s) {}
 };
 
 class LoadError : public BaseException {
 public:
-       LoadError(std::string s): BaseException(s) {}
+       LoadError(const std::string &s): BaseException(s) {}
 };
 
 class ContainerFullException : public BaseException {
 public:
-       ContainerFullException(std::string s): BaseException(s) {}
+       ContainerFullException(const std::string &s): BaseException(s) {}
 };
 
 class SettingNotFoundException : public BaseException {
 public:
-       SettingNotFoundException(std::string s): BaseException(s) {}
+       SettingNotFoundException(const std::string &s): BaseException(s) {}
 };
 
 class InvalidFilenameException : public BaseException {
 public:
-       InvalidFilenameException(std::string s): BaseException(s) {}
+       InvalidFilenameException(const std::string &s): BaseException(s) {}
 };
 
 class ProcessingLimitException : public BaseException {
 public:
-       ProcessingLimitException(std::string s): BaseException(s) {}
+       ProcessingLimitException(const std::string &s): BaseException(s) {}
 };
 
 class CommandLineError : public BaseException {
 public:
-       CommandLineError(std::string s): BaseException(s) {}
+       CommandLineError(const std::string &s): BaseException(s) {}
 };
 
 class ItemNotFoundException : public BaseException {
 public:
-       ItemNotFoundException(std::string s): BaseException(s) {}
+       ItemNotFoundException(const std::string &s): BaseException(s) {}
 };
 
 class ServerError : public BaseException {
 public:
-       ServerError(std::string s): BaseException(s) {}
+       ServerError(const std::string &s): BaseException(s) {}
 };
 
 // Only used on Windows (SEH)
 class FatalSystemException : public BaseException {
 public:
-       FatalSystemException(std::string s): BaseException(s) {}
+       FatalSystemException(const std::string &s): BaseException(s) {}
 };
 
 /*
@@ -126,7 +126,7 @@ public:
        InvalidPositionException():
                BaseException("Somebody tried to get/set something in a nonexistent position.")
        {}
-       InvalidPositionException(std::string s):
+       InvalidPositionException(const std::string &s):
                BaseException(s)
        {}
 };
index 858894e5ccd661ecce3a0714ad7befe045125965..3fc1b5746a8a293f3c9a8e14da6e0bdd89549c79 100644 (file)
@@ -149,8 +149,8 @@ class GUIFormSpecMenu : public GUIModalMenu
                FieldSpec()
                {
                }
-               FieldSpec(const std::wstring name, const std::wstring label,
-                               const std::wstring fdeflt, int id) :
+               FieldSpec(const std::wstring &name, const std::wstring &label,
+                         const std::wstring &fdeflt, int id) :
                        fname(name),
                        flabel(label),
                        fdefault(fdeflt),
index dedcc98978ff1ceb241dba2af5f32c9e22f75af3..f11401a1587d6e2aa1636472811b5bb6cdd758cf 100644 (file)
@@ -66,7 +66,7 @@ struct ModSpec
        bool is_modpack;
        // if modpack:
        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_),
                path(path_),
                depends(),
index 898271743ee099ad1793aa9827cb9022c414373f..e28a34eeed61d3473fd01a845a29363bedb2cc5d 100644 (file)
@@ -43,7 +43,7 @@ class ModNameStorer
 private:
        lua_State *L;
 public:
-       ModNameStorer(lua_State *L_, const std::string modname):
+       ModNameStorer(lua_State *L_, const std::string &modname):
                L(L_)
        {
                // Store current modname in registry
index 7eb78f3ef6756a1d319a62ab11be2c62eb57191e..ba7ac1eceedc1ac0b9d32e957b4cf5d825adf993 100644 (file)
@@ -3046,8 +3046,8 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
        }
 }
 
-void Server::SendShowFormspecMessage(u16 peer_id, const std::string formspec,
-                                       const std::string formname)
+void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
+                                     const std::string &formname)
 {
        DSTACK(__FUNCTION_NAME);
 
@@ -3871,8 +3871,8 @@ struct SendableMediaAnnouncement
        std::string name;
        std::string sha1_digest;
 
-       SendableMediaAnnouncement(const std::string name_="",
-                       const std::string sha1_digest_=""):
+       SendableMediaAnnouncement(const std::string &name_="",
+                                 const std::string &sha1_digest_=""):
                name(name_),
                sha1_digest(sha1_digest_)
        {}
@@ -3933,8 +3933,8 @@ struct SendableMedia
        std::string path;
        std::string data;
 
-       SendableMedia(const std::string &name_="", const std::string path_="",
-                       const std::string &data_=""):
+       SendableMedia(const std::string &name_="", const std::string &path_="",
+                     const std::string &data_=""):
                name(name_),
                path(path_),
                data(data_)
@@ -4385,7 +4385,7 @@ std::string Server::getBanDescription(const std::string &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);
        if(!player)
@@ -4498,7 +4498,7 @@ bool Server::overrideDayNightRatio(Player *player, bool do_override,
        return true;
 }
 
-void Server::notifyPlayers(const std::wstring msg)
+void Server::notifyPlayers(const std::wstring &msg)
 {
        SendChatMessage(PEER_ID_INEXISTENT,msg);
 }
index 7ad9bcafb3f4dd443c98cc65ff7f0a04f006b116..7813eabbd6d5828a9e4116b8b28dfe993fb1b5ec 100644 (file)
@@ -122,8 +122,8 @@ struct MediaInfo
        std::string path;
        std::string sha1_digest;
 
-       MediaInfo(const std::string path_="",
-                       const std::string sha1_digest_=""):
+       MediaInfo(const std::string &path_="",
+                 const std::string &sha1_digest_=""):
                path(path_),
                sha1_digest(sha1_digest_)
        {
@@ -229,8 +229,8 @@ public:
        void unsetIpBanned(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 notifyPlayers(const std::wstring msg);
+       void notifyPlayer(const char *name, const std::wstring &msg);
+       void notifyPlayers(const std::wstring &msg);
        void spawnParticle(const char *playername,
                v3f pos, v3f velocity, v3f acceleration,
                float expirationtime, float size,
@@ -357,7 +357,7 @@ private:
        void SendMovePlayer(u16 peer_id);
        void SendPlayerPrivileges(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 SendHUDRemove(u16 peer_id, u32 id);
        void SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value);
index 0cfbc279829a95978c94979d3339eb4be67332d8..d27526b55b5522877c8a0b5bfb8f52a663a14c66 100644 (file)
@@ -391,7 +391,7 @@ public:
        }
 
        /* If buffer does not exist, consult the fetcher */
-       SoundBuffer* getFetchBuffer(const std::string name)
+       SoundBuffer* getFetchBuffer(const std::string &name)
        {
                SoundBuffer *buf = getBuffer(name);
                if(buf)