summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/content_cao.cpp16
-rw-r--r--src/client/content_cao.h4
-rw-r--r--src/client/guiscalingfilter.cpp2
-rw-r--r--src/client/guiscalingfilter.h2
-rw-r--r--src/client/hud.cpp2
-rw-r--r--src/client/hud.h2
-rw-r--r--src/client/tile.cpp3
-rw-r--r--src/gui/guiChatConsole.cpp2
-rw-r--r--src/gui/guiChatConsole.h2
-rw-r--r--src/gui/guiEngine.cpp4
-rw-r--r--src/gui/guiEngine.h4
-rw-r--r--src/gui/guiFormSpecMenu.cpp2
-rw-r--r--src/gui/guiFormSpecMenu.h2
-rw-r--r--src/inventorymanager.cpp2
-rw-r--r--src/inventorymanager.h2
-rw-r--r--src/map.cpp2
-rw-r--r--src/map.h2
-rw-r--r--src/server.cpp4
-rw-r--r--src/server.h4
-rw-r--r--src/translation.cpp4
-rw-r--r--src/unittest/test_areastore.cpp2
21 files changed, 41 insertions, 28 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index b169ba75f..cf22aa0ed 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -1062,7 +1062,7 @@ void GenericCAO::updateTexturePos()
}
}
-void GenericCAO::updateTextures(std::string mod)
+void GenericCAO::updateTextures(const std::string &modref)
{
ITextureSource *tsrc = m_client->tsrc();
@@ -1071,9 +1071,21 @@ void GenericCAO::updateTextures(std::string mod)
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
m_previous_texture_modifier = m_current_texture_modifier;
- m_current_texture_modifier = mod;
+ m_current_texture_modifier = modref;
m_glow = m_prop.glow;
+ // Create a reference to the copy of "modref" just created. The
+ // following code will then use this reference instead of the
+ // original parameter which was passed by reference. This is
+ // necessary as "modref" can be a class member and there is a swap on
+ // those class members which can get triggered by the rest of the
+ // code of this method. This is faster than passing the "mod" by
+ // value because it reuses the copy made by the assignment to
+ // m_current_texture_modifier for the "mod" instead of having two
+ // copies, one for "mod" and another one (created from "mod") for
+ // the m_current_texture_modifier class member.
+ const std::string &mod = m_current_texture_modifier;
+
video::E_MATERIAL_TYPE material_type = (m_prop.use_texture_alpha) ?
video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
diff --git a/src/client/content_cao.h b/src/client/content_cao.h
index 3ce628d30..320607061 100644
--- a/src/client/content_cao.h
+++ b/src/client/content_cao.h
@@ -225,9 +225,7 @@ public:
void updateTexturePos();
- // std::string copy is mandatory as mod can be a class member and there is a swap
- // on those class members... do NOT pass by reference
- void updateTextures(std::string mod);
+ void updateTextures(const std::string &modref);
void updateAnimation();
diff --git a/src/client/guiscalingfilter.cpp b/src/client/guiscalingfilter.cpp
index 3b4377da5..312f93939 100644
--- a/src/client/guiscalingfilter.cpp
+++ b/src/client/guiscalingfilter.cpp
@@ -39,7 +39,7 @@ std::map<io::path, video::ITexture *> g_txrCache;
/* Manually insert an image into the cache, useful to avoid texture-to-image
* conversion whenever we can intercept it.
*/
-void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value)
+void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value)
{
if (!g_settings->getBool("gui_scaling_filter"))
return;
diff --git a/src/client/guiscalingfilter.h b/src/client/guiscalingfilter.h
index 4661bf8da..a5cd78511 100644
--- a/src/client/guiscalingfilter.h
+++ b/src/client/guiscalingfilter.h
@@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* Manually insert an image into the cache, useful to avoid texture-to-image
* conversion whenever we can intercept it.
*/
-void guiScalingCache(io::path key, video::IVideoDriver *driver, video::IImage *value);
+void guiScalingCache(const io::path &key, video::IVideoDriver *driver, video::IImage *value);
// Manually clear the cache, e.g. when switching to different worlds.
void guiScalingCacheClear();
diff --git a/src/client/hud.cpp b/src/client/hud.cpp
index 1a2287a13..cb58fb500 100644
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -372,7 +372,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
}
-void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
+void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture,
s32 count, v2s32 offset, v2s32 size)
{
const video::SColor color(255, 255, 255, 255);
diff --git a/src/client/hud.h b/src/client/hud.h
index e9bcdf4e2..693d2adee 100644
--- a/src/client/hud.h
+++ b/src/client/hud.h
@@ -81,7 +81,7 @@ public:
void drawLuaElements(const v3s16 &camera_offset);
private:
- void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture,
+ void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, const std::string &texture,
s32 count, v2s32 offset, v2s32 size = v2s32());
void drawItems(v2s32 upperleftpos, v2s32 screen_offset, s32 itemcount,
diff --git a/src/client/tile.cpp b/src/client/tile.cpp
index 4911013ae..72f7358b1 100644
--- a/src/client/tile.cpp
+++ b/src/client/tile.cpp
@@ -131,7 +131,8 @@ std::string getTexturePath(const std::string &filename)
Check from texture_path
*/
for (const auto &path : getTextureDirs()) {
- std::string testpath = path + DIR_DELIM + filename;
+ std::string testpath = path + DIR_DELIM;
+ testpath.append(filename);
// Check all filename extensions. Returns "" if not found.
fullpath = getImagePath(testpath);
if (!fullpath.empty())
diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp
index 1ccb4e6d1..42348beb3 100644
--- a/src/gui/guiChatConsole.cpp
+++ b/src/gui/guiChatConsole.cpp
@@ -139,7 +139,7 @@ f32 GUIChatConsole::getDesiredHeight() const
return m_desired_height_fraction;
}
-void GUIChatConsole::replaceAndAddToHistory(std::wstring line)
+void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
{
ChatPrompt& prompt = m_chat_backend->getPrompt();
prompt.addToHistory(prompt.getLine());
diff --git a/src/gui/guiChatConsole.h b/src/gui/guiChatConsole.h
index ef8a87673..7be40e27c 100644
--- a/src/gui/guiChatConsole.h
+++ b/src/gui/guiChatConsole.h
@@ -60,7 +60,7 @@ public:
f32 getDesiredHeight() const;
// Replace actual line when adding the actual to the history (if there is any)
- void replaceAndAddToHistory(std::wstring line);
+ void replaceAndAddToHistory(const std::wstring &line);
// Change how the cursor looks
void setCursor(
diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp
index 6030a5bfb..f0a8f40eb 100644
--- a/src/gui/guiEngine.cpp
+++ b/src/gui/guiEngine.cpp
@@ -518,7 +518,7 @@ void GUIEngine::drawFooter(video::IVideoDriver *driver)
}
/******************************************************************************/
-bool GUIEngine::setTexture(texture_layer layer, std::string texturepath,
+bool GUIEngine::setTexture(texture_layer layer, const std::string &texturepath,
bool tile_image, unsigned int minsize)
{
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
@@ -593,7 +593,7 @@ void GUIEngine::updateTopLeftTextSize()
}
/******************************************************************************/
-s32 GUIEngine::playSound(SimpleSoundSpec spec, bool looped)
+s32 GUIEngine::playSound(const SimpleSoundSpec &spec, bool looped)
{
s32 handle = m_sound_manager->playSound(spec, looped);
return handle;
diff --git a/src/gui/guiEngine.h b/src/gui/guiEngine.h
index 409ba94c4..0ff5030c0 100644
--- a/src/gui/guiEngine.h
+++ b/src/gui/guiEngine.h
@@ -247,7 +247,7 @@ private:
* @param layer draw layer to specify texture
* @param texturepath full path of texture to load
*/
- bool setTexture(texture_layer layer, std::string texturepath,
+ bool setTexture(texture_layer layer, const std::string &texturepath,
bool tile_image, unsigned int minsize);
/**
@@ -296,7 +296,7 @@ private:
clouddata m_cloud;
/** start playing a sound and return handle */
- s32 playSound(SimpleSoundSpec spec, bool looped);
+ s32 playSound(const SimpleSoundSpec &spec, bool looped);
/** stop playing a sound started with playSound() */
void stopSound(s32 handle);
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 92e654765..e2aed420c 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -86,7 +86,7 @@ inline u32 clamp_u8(s32 value)
GUIFormSpecMenu::GUIFormSpecMenu(JoystickController *joystick,
gui::IGUIElement *parent, s32 id, IMenuManager *menumgr,
Client *client, ISimpleTextureSource *tsrc, IFormSource *fsrc, TextDest *tdst,
- std::string formspecPrepend,
+ const std::string &formspecPrepend,
bool remap_dbl_click):
GUIModalMenu(RenderingEngine::get_gui_env(), parent, id, menumgr),
m_invmgr(client),
diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h
index d75a108d4..33f88d8c0 100644
--- a/src/gui/guiFormSpecMenu.h
+++ b/src/gui/guiFormSpecMenu.h
@@ -287,7 +287,7 @@ public:
ISimpleTextureSource *tsrc,
IFormSource* fs_src,
TextDest* txt_dst,
- std::string formspecPrepend,
+ const std::string &formspecPrepend,
bool remap_dbl_click = true);
~GUIFormSpecMenu();
diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp
index 51a472a56..24d1fa6ff 100644
--- a/src/inventorymanager.cpp
+++ b/src/inventorymanager.cpp
@@ -93,7 +93,7 @@ void InventoryLocation::deSerialize(std::istream &is)
}
}
-void InventoryLocation::deSerialize(std::string s)
+void InventoryLocation::deSerialize(const std::string &s)
{
std::istringstream is(s, std::ios::binary);
deSerialize(is);
diff --git a/src/inventorymanager.h b/src/inventorymanager.h
index 30a82d4bf..06517f40f 100644
--- a/src/inventorymanager.h
+++ b/src/inventorymanager.h
@@ -97,7 +97,7 @@ struct InventoryLocation
std::string dump() const;
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
- void deSerialize(std::string s);
+ void deSerialize(const std::string &s);
};
struct InventoryAction;
diff --git a/src/map.cpp b/src/map.cpp
index 0114867e0..3d1e74790 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1717,7 +1717,7 @@ bool ServerMap::loadFromFolders() {
return false;
}
-void ServerMap::createDirs(std::string path)
+void ServerMap::createDirs(const std::string &path)
{
if (!fs::CreateAllDirs(path)) {
m_dout<<"ServerMap: Failed to create directory "
diff --git a/src/map.h b/src/map.h
index 7ef34b279..251ac297f 100644
--- a/src/map.h
+++ b/src/map.h
@@ -389,7 +389,7 @@ public:
Misc. helper functions for fiddling with directory and file
names when saving
*/
- void createDirs(std::string path);
+ void createDirs(const std::string &path);
// returns something like "map/sectors/xxxxxxxx"
std::string getSectorDir(v2s16 pos, int layout = 2);
// dirname: final directory name
diff --git a/src/server.cpp b/src/server.cpp
index 496170da3..7167a6686 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3207,7 +3207,7 @@ bool Server::hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount)
return true;
}
-void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
+void Server::hudSetHotbarImage(RemotePlayer *player, const std::string &name)
{
if (!player)
return;
@@ -3216,7 +3216,7 @@ void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_IMAGE, name);
}
-void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
+void Server::hudSetHotbarSelectedImage(RemotePlayer *player, const std::string &name)
{
if (!player)
return;
diff --git a/src/server.h b/src/server.h
index 5e58ac9e6..4232653eb 100644
--- a/src/server.h
+++ b/src/server.h
@@ -296,8 +296,8 @@ public:
bool hudChange(RemotePlayer *player, u32 id, HudElementStat stat, void *value);
bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
- void hudSetHotbarImage(RemotePlayer *player, std::string name);
- void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);
+ void hudSetHotbarImage(RemotePlayer *player, const std::string &name);
+ void hudSetHotbarSelectedImage(RemotePlayer *player, const std::string &name);
Address getPeerAddress(session_t peer_id);
diff --git a/src/translation.cpp b/src/translation.cpp
index 7ddd95591..d17467ce7 100644
--- a/src/translation.cpp
+++ b/src/translation.cpp
@@ -149,6 +149,8 @@ void Translations::loadTranslation(const std::string &data)
<< wide_to_utf8(oword1) << "\"" << std::endl;
}
- m_translations[textdomain + L"|" + oword1] = oword2;
+ std::wstring translation_index = textdomain + L"|";
+ translation_index.append(oword1);
+ m_translations[translation_index] = oword2;
}
}
diff --git a/src/unittest/test_areastore.cpp b/src/unittest/test_areastore.cpp
index 62d446f5c..a6d4706e4 100644
--- a/src/unittest/test_areastore.cpp
+++ b/src/unittest/test_areastore.cpp
@@ -152,7 +152,7 @@ void TestAreaStore::testSerialization()
1 + 2 +
6 + 6 + 2 + 6 +
6 + 6 + 2 + 6);
- UASSERTEQ(std::string, str, str_wanted);
+ UASSERTEQ(const std::string &, str, str_wanted);
std::istringstream is(str);
store.deserialize(is);