summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-29 21:44:11 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-29 21:44:11 +0300
commit337a52a41ea44570da65586403f14248042f0169 (patch)
tree27f58dd5f9c9f50310c94c649595a9e7f8e00455 /src
parent36c45ae7d8d2577a900ec266b64448d4b488013d (diff)
downloadplus-337a52a41ea44570da65586403f14248042f0169.tar.gz
plus-337a52a41ea44570da65586403f14248042f0169.tar.bz2
plus-337a52a41ea44570da65586403f14248042f0169.tar.xz
plus-337a52a41ea44570da65586403f14248042f0169.zip
Use std::move in some places.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/fs/virtfs/fs.cpp11
-rw-r--r--src/fs/virtfs/fsdir.cpp3
-rw-r--r--src/gui/popups/itempopup.cpp20
-rw-r--r--src/gui/widgets/setupitem.cpp3
-rw-r--r--src/gui/widgets/staticbrowserbox.cpp3
-rw-r--r--src/gui/windows/logindialog.cpp3
-rw-r--r--src/gui/windows/minimap.cpp3
-rw-r--r--src/input/inputmanager.cpp3
-rw-r--r--src/net/ea/playerrecv.cpp3
-rw-r--r--src/resources/db/itemdb.cpp3
-rw-r--r--src/resources/db/unitsdb.cpp3
-rw-r--r--src/utils/stdmove.h30
14 files changed, 66 insertions, 24 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9441e11fe..2a3f68032 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1452,6 +1452,7 @@ SET(SRCS
utils/sdlpixel.h
utils/sdlsharedhelper.cpp
utils/sdlsharedhelper.h
+ utils/stdmove.h
gui/widgets/widget.h
listeners/weightlistener.h
listeners/widgetlistener.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 6fac4b0ed..0e6a13dd3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -229,6 +229,7 @@ BASE_SRC += events/actionevent.h \
utils/sdlpixel.h \
utils/sdlsharedhelper.cpp \
utils/sdlsharedhelper.h \
+ utils/stdmove.h \
gui/widgets/widget.h \
listeners/weightlistener.h \
listeners/widgetlistener.h \
diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp
index d9973d79b..9fe755560 100644
--- a/src/fs/virtfs/fs.cpp
+++ b/src/fs/virtfs/fs.cpp
@@ -34,6 +34,7 @@
#include "utils/checkutils.h"
#include "utils/foreach.h"
+#include "utils/stdmove.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -153,7 +154,7 @@ namespace VirtFs
return list;
}
- std::string rootDir = dirName;
+ std::string rootDir = STD_MOVE(dirName);
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
StringVect &names = list->names;
@@ -178,7 +179,7 @@ namespace VirtFs
return;
}
- std::string rootDir = dirName;
+ std::string rootDir = STD_MOVE(dirName);
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
@@ -200,7 +201,7 @@ namespace VirtFs
return;
}
- std::string rootDir = dirName;
+ std::string rootDir = STD_MOVE(dirName);
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
@@ -223,7 +224,7 @@ namespace VirtFs
return;
}
- std::string rootDir = dirName;
+ std::string rootDir = STD_MOVE(dirName);
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
@@ -243,7 +244,7 @@ namespace VirtFs
name.c_str());
return false;
}
- std::string dirName = name;
+ std::string dirName = STD_MOVE(name);
if (findLast(dirName, std::string(dirSeparator)) == false)
dirName += dirSeparator;
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index d4e9ce900..59097e5be 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -32,6 +32,7 @@
#include "utils/checkutils.h"
#include "utils/foreach.h"
+#include "utils/stdmove.h"
#include "utils/stringutils.h"
#include <dirent.h>
@@ -274,7 +275,7 @@ namespace FsDir
bool setWriteDir(std::string newDir)
{
prepareFsPath(newDir);
- mWriteDir = newDir;
+ mWriteDir = STD_MOVE(newDir);
if (findLast(mWriteDir, std::string(dirSeparator)) == false)
mWriteDir += dirSeparator;
return true;
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
index 5c5dfd19e..5179627e1 100644
--- a/src/gui/popups/itempopup.cpp
+++ b/src/gui/popups/itempopup.cpp
@@ -34,7 +34,14 @@
#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
+#include "net/beinghandler.h"
+#include "net/net.h"
+
+#include "utils/foreach.h"
#include "utils/gettext.h"
+#include "utils/stdmove.h"
+
+#include "utils/translation/podict.h"
#include "resources/iteminfo.h"
@@ -49,13 +56,6 @@
#include "resources/loaders/imageloader.h"
-#include "net/beinghandler.h"
-#include "net/net.h"
-
-#include "utils/foreach.h"
-
-#include "utils/translation/podict.h"
-
#include "debug.h"
ItemPopup *itemPopup = nullptr;
@@ -208,8 +208,8 @@ void ItemPopup::setItem(const ItemInfo &item,
cardsStr = getCardsString(cards);
optionsStr = getOptionsString(options);
}
- mItemOptionsStr = optionsStr;
- mCardsStr = cardsStr;
+ mItemOptionsStr = STD_MOVE(optionsStr);
+ mCardsStr = STD_MOVE(cardsStr);
if (id == -1)
id = item.getId();
@@ -269,7 +269,7 @@ void ItemPopup::setItem(const ItemInfo &item,
mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
UnitsDb::formatWeight(item.getWeight()).c_str()), 196);
mItemCards->setTextWrapped(mCardsStr, 196);
- mItemOptions->setTextWrapped(optionsStr, 196);
+ mItemOptions->setTextWrapped(mItemOptionsStr, 196);
int minWidth = mItemName->getWidth() + space;
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 8d6296d52..e4b40f9be 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -44,6 +44,7 @@
#include "utils/base64.h"
#include "utils/gettext.h"
+#include "utils/stdmove.h"
#include "utils/mathutils.h"
#include "debug.h"
@@ -324,7 +325,7 @@ void SetupItemTextField::save()
std::string normalValue = mValue;
mValue = encodeBase64String(mValue);
SetupItem::save();
- mValue = normalValue;
+ mValue = STD_MOVE(normalValue);
}
else
{
diff --git a/src/gui/widgets/staticbrowserbox.cpp b/src/gui/widgets/staticbrowserbox.cpp
index ef51660c0..7be4b780e 100644
--- a/src/gui/widgets/staticbrowserbox.cpp
+++ b/src/gui/widgets/staticbrowserbox.cpp
@@ -46,6 +46,7 @@
#include "utils/browserboxtools.h"
#include "utils/checkutils.h"
#include "utils/foreach.h"
+#include "utils/stdmove.h"
#include "utils/stringutils.h"
#include "utils/translation/podict.h"
@@ -256,7 +257,7 @@ void StaticBrowserBox::addRow(const std::string &row,
mTextRowLinksCount.push_back(linksCount);
}
- std::string plain = newRow;
+ std::string plain = STD_MOVE(newRow);
// workaround if used only one string started from bold
// width for this string can be calculated wrong
// this workaround fix width if string start from bold sign
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index e99d1b68e..21af69b91 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -48,6 +48,7 @@
#include "net/updatetypeoperators.h"
#include "utils/delete2.h"
+#include "utils/stdmove.h"
#include "debug.h"
@@ -357,7 +358,7 @@ void LoginDialog::prepareUpdate()
if (!str.empty() && checkPath(str))
{
mLoginData->updateHost = str;
- *mUpdateHost = str;
+ *mUpdateHost = STD_MOVE(str);
}
else
{
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 95d606618..7f48f4a10 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -54,6 +54,7 @@
#include "utils/gettext.h"
#include "utils/foreach.h"
#include "utils/sdlcheckutils.h"
+#include "utils/stdmove.h"
#include "debug.h"
@@ -190,7 +191,7 @@ void Minimap::setMap(const Map *const map)
tempname = pathJoin("graphics/minimaps",
map->getFilename()).append(".png");
if (VirtFs::exists(tempname))
- minimapName = tempname;
+ minimapName = STD_MOVE(tempname);
}
if (!minimapName.empty())
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index 13298f2e3..fa42ffe32 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -55,6 +55,7 @@
#include "utils/checkutils.h"
#include "utils/gettext.h"
+#include "utils/stdmove.h"
#include "utils/timer.h"
#include "gui/focushandler.h"
@@ -468,7 +469,7 @@ void InputManager::updateKeyString(const InputFunction &ki,
}
else
{
- mKeyStr[actionIdx] = keyStr;
+ mKeyStr[actionIdx] = STD_MOVE(keyStr);
}
}
diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp
index 93108b39d..edc604907 100644
--- a/src/net/ea/playerrecv.cpp
+++ b/src/net/ea/playerrecv.cpp
@@ -44,6 +44,7 @@
#include "net/playerhandler.h"
+#include "utils/stdmove.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -256,7 +257,7 @@ void PlayerRecv::processPlayerClientCommand(Net::MessageIn &msg)
if (!parse2Str(command, cmd, args))
{
- cmd = command;
+ cmd = STD_MOVE(command);
args.clear();
}
inputManager.executeRemoteChatCommand(cmd, args, nullptr);
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 440b69d16..57000cf95 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -45,6 +45,7 @@
#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/foreach.h"
+#include "utils/stdmove.h"
#include "utils/stringmap.h"
#include "utils/translation/podict.h"
@@ -355,7 +356,7 @@ void ItemDB::loadXmlFile(const std::string &fileName,
SpriteDisplay display;
display.image = image;
if (!floor.empty())
- display.floor = floor;
+ display.floor = STD_MOVE(floor);
else
display.floor = image;
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
index 9481406c4..e9b310c6d 100644
--- a/src/resources/db/unitsdb.cpp
+++ b/src/resources/db/unitsdb.cpp
@@ -27,6 +27,7 @@
#include "const/resources/currency.h"
#include "utils/checkutils.h"
+#include "utils/stdmove.h"
#include "resources/beingcommon.h"
@@ -372,7 +373,7 @@ static std::string splitNumber(std::string str,
if (!result.empty())
result = std::string(str).append(separator).append(result);
else
- result = str;
+ result = STD_MOVE(str);
}
}
diff --git a/src/utils/stdmove.h b/src/utils/stdmove.h
new file mode 100644
index 000000000..b72b941aa
--- /dev/null
+++ b/src/utils/stdmove.h
@@ -0,0 +1,30 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UTILS_STDMOVE_H
+#define UTILS_STDMOVE_H
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#define STD_MOVE(var) std::move(var)
+#else // __GXX_EXPERIMENTAL_CXX0X__
+#define STD_MOVE(var) (var)
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
+#endif // UTILS_STDMOVE_H