From d3d7a663c6c051e8a43f3c4b8563a1ade6b0b404 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sat, 29 Jul 2023 11:44:39 +0400 Subject: [PATCH] Move some objects instead of copying --- apps/essimporter/converter.cpp | 2 +- apps/essimporter/importcellref.cpp | 2 +- apps/launcher/settingspage.cpp | 2 +- apps/mwiniimporter/importer.cpp | 3 +-- apps/opencs/model/filter/notnode.cpp | 2 +- apps/opencs/model/filter/unarynode.cpp | 2 +- apps/opencs/model/prefs/coloursetting.cpp | 2 +- apps/opencs/model/prefs/stringsetting.cpp | 2 +- apps/opencs/model/prefs/stringsetting.hpp | 4 ++-- apps/opencs/model/world/actoradapter.cpp | 2 +- apps/opencs/view/render/scenewidget.cpp | 8 ++++---- apps/opencs/view/render/scenewidget.hpp | 6 +++--- apps/opencs/view/render/terraintexturemode.cpp | 12 +++++------- apps/opencs/view/render/terraintexturemode.hpp | 4 ++-- apps/opencs/view/world/nestedtable.cpp | 2 +- apps/opencs/view/world/nestedtable.hpp | 2 +- apps/openmw/mwgui/bookpage.cpp | 4 ++-- apps/openmw/mwgui/charactercreation.cpp | 6 +++--- apps/openmw/mwgui/dialogue.cpp | 2 +- apps/openmw/mwgui/journalbooks.cpp | 12 ++++++------ apps/openmw/mwgui/journalwindow.cpp | 8 ++++---- apps/openmw/mwgui/journalwindow.hpp | 2 +- apps/openmw/mwgui/statswindow.cpp | 2 +- apps/openmw/mwlua/types/types.hpp | 2 +- apps/openmw/mwrender/animation.hpp | 2 +- apps/openmw/mwrender/luminancecalculator.cpp | 6 +++--- apps/openmw/mwrender/navmesh.cpp | 2 +- apps/openmw/mwworld/containerstore.hpp | 2 +- components/contentselector/model/contentmodel.cpp | 2 +- components/contentselector/model/contentmodel.hpp | 2 +- components/contentselector/model/esmfile.cpp | 2 +- components/contentselector/model/esmfile.hpp | 2 +- components/contentselector/model/loadordererror.hpp | 2 +- components/esm3/transport.cpp | 2 +- components/fallback/validate.cpp | 2 +- components/fontloader/fontloader.cpp | 2 +- components/fx/stateupdater.hpp | 5 ++++- components/sceneutil/controller.cpp | 8 ++++---- components/sceneutil/riggeometryosgaextension.cpp | 2 +- components/sceneutil/screencapture.cpp | 2 +- components/stereo/stereomanager.cpp | 4 ++-- components/stereo/stereomanager.hpp | 2 +- 42 files changed, 73 insertions(+), 73 deletions(-) diff --git a/apps/essimporter/converter.cpp b/apps/essimporter/converter.cpp index 42dde71979..4751fd9497 100644 --- a/apps/essimporter/converter.cpp +++ b/apps/essimporter/converter.cpp @@ -300,7 +300,7 @@ namespace ESSImport ESM::CustomMarker marker; marker.mWorldX = notepos[0]; marker.mWorldY = notepos[1]; - marker.mNote = note; + marker.mNote = std::move(note); marker.mCell = cell.mId; mMarkers.push_back(marker); } diff --git a/apps/essimporter/importcellref.cpp b/apps/essimporter/importcellref.cpp index 7c2159299a..a900440a96 100644 --- a/apps/essimporter/importcellref.cpp +++ b/apps/essimporter/importcellref.cpp @@ -101,7 +101,7 @@ namespace ESSImport if (esm.isNextSub("XNAM")) mActorData.mSelectedEnchantItem = esm.getHString(); else - mActorData.mSelectedSpell = id; + mActorData.mSelectedSpell = std::move(id); if (esm.isNextSub("YNAM")) esm.skipHSub(); // 4 byte, 0 diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp index cf7b208d53..07570272dd 100644 --- a/apps/launcher/settingspage.cpp +++ b/apps/launcher/settingspage.cpp @@ -418,7 +418,7 @@ void Launcher::SettingsPage::saveSettings() void Launcher::SettingsPage::slotLoadedCellsChanged(QStringList cellNames) { - loadCellsForAutocomplete(cellNames); + loadCellsForAutocomplete(std::move(cellNames)); } void Launcher::SettingsPage::slotAnimSourcesToggled(bool checked) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index ddc571d5c6..bc322649e7 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -522,7 +522,6 @@ void MwIniImporter::importGameFiles( multistrmap& cfg, const multistrmap& ini, const std::filesystem::path& iniFilename) const { std::vector> contentFiles; - std::string baseGameFile("Game Files:GameFile"); std::time_t defaultTime = 0; ToUTF8::Utf8Encoder encoder(mEncoding); @@ -538,7 +537,7 @@ void MwIniImporter::importGameFiles( auto it = ini.begin(); for (int i = 0; it != ini.end(); i++) { - std::string gameFile = baseGameFile; + std::string gameFile("Game Files:GameFile"); gameFile.append(std::to_string(i)); it = ini.find(gameFile); diff --git a/apps/opencs/model/filter/notnode.cpp b/apps/opencs/model/filter/notnode.cpp index 80162dc9e5..ad86fff80c 100644 --- a/apps/opencs/model/filter/notnode.cpp +++ b/apps/opencs/model/filter/notnode.cpp @@ -9,7 +9,7 @@ namespace CSMWorld } CSMFilter::NotNode::NotNode(std::shared_ptr child) - : UnaryNode(child, "not") + : UnaryNode(std::move(child), "not") { } diff --git a/apps/opencs/model/filter/unarynode.cpp b/apps/opencs/model/filter/unarynode.cpp index 277ef406ce..0fefab1992 100644 --- a/apps/opencs/model/filter/unarynode.cpp +++ b/apps/opencs/model/filter/unarynode.cpp @@ -3,7 +3,7 @@ #include CSMFilter::UnaryNode::UnaryNode(std::shared_ptr child, const std::string& name) - : mChild(child) + : mChild(std::move(child)) , mName(name) { } diff --git a/apps/opencs/model/prefs/coloursetting.cpp b/apps/opencs/model/prefs/coloursetting.cpp index e33ae78a1a..86f3a5d772 100644 --- a/apps/opencs/model/prefs/coloursetting.cpp +++ b/apps/opencs/model/prefs/coloursetting.cpp @@ -16,7 +16,7 @@ CSMPrefs::ColourSetting::ColourSetting( Category* parent, QMutex* mutex, const std::string& key, const std::string& label, QColor default_) : Setting(parent, mutex, key, label) - , mDefault(default_) + , mDefault(std::move(default_)) , mWidget(nullptr) { } diff --git a/apps/opencs/model/prefs/stringsetting.cpp b/apps/opencs/model/prefs/stringsetting.cpp index 9016e2c8cd..2a8fdd587a 100644 --- a/apps/opencs/model/prefs/stringsetting.cpp +++ b/apps/opencs/model/prefs/stringsetting.cpp @@ -12,7 +12,7 @@ #include "state.hpp" CSMPrefs::StringSetting::StringSetting( - Category* parent, QMutex* mutex, const std::string& key, const std::string& label, std::string default_) + Category* parent, QMutex* mutex, const std::string& key, const std::string& label, std::string_view default_) : Setting(parent, mutex, key, label) , mDefault(default_) , mWidget(nullptr) diff --git a/apps/opencs/model/prefs/stringsetting.hpp b/apps/opencs/model/prefs/stringsetting.hpp index 4494b1a95b..4b5499ef86 100644 --- a/apps/opencs/model/prefs/stringsetting.hpp +++ b/apps/opencs/model/prefs/stringsetting.hpp @@ -23,8 +23,8 @@ namespace CSMPrefs QLineEdit* mWidget; public: - StringSetting( - Category* parent, QMutex* mutex, const std::string& key, const std::string& label, std::string default_); + StringSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label, + std::string_view default_); StringSetting& setTooltip(const std::string& tooltip); diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index e57ad648ba..3a54bb3b0e 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -533,7 +533,7 @@ namespace CSMWorld auto& npc = dynamic_cast&>(mReferenceables.getRecord(index)).get(); RaceDataPtr raceData = getRaceData(npc.mRace); - data->reset_data(id, "", false, !npc.isMale(), raceData); + data->reset_data(id, "", false, !npc.isMale(), std::move(raceData)); // Add head and hair data->setPart(ESM::PRT_Head, npc.mHead, 0); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 6961a9d1a5..3562d2ba6e 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -154,7 +154,7 @@ namespace CSVRender SceneWidget::SceneWidget(std::shared_ptr resourceSystem, QWidget* parent, Qt::WindowFlags f, bool retrieveInput) : RenderWidget(parent, f) - , mResourceSystem(resourceSystem) + , mResourceSystem(std::move(resourceSystem)) , mLighting(nullptr) , mHasDefaultAmbient(false) , mIsExterior(true) @@ -225,7 +225,7 @@ namespace CSVRender mResourceSystem->releaseGLObjects(mView->getCamera()->getGraphicsContext()->getState()); } - osg::ref_ptr SceneWidget::createGradientRectangle(QColor bgColour, QColor gradientColour) + osg::ref_ptr SceneWidget::createGradientRectangle(QColor& bgColour, QColor& gradientColour) { osg::ref_ptr geometry = new osg::Geometry; @@ -266,7 +266,7 @@ namespace CSVRender return geometry; } - osg::ref_ptr SceneWidget::createGradientCamera(QColor bgColour, QColor gradientColour) + osg::ref_ptr SceneWidget::createGradientCamera(QColor& bgColour, QColor& gradientColour) { osg::ref_ptr camera = new osg::Camera(); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); @@ -288,7 +288,7 @@ namespace CSVRender return camera; } - void SceneWidget::updateGradientCamera(QColor bgColour, QColor gradientColour) + void SceneWidget::updateGradientCamera(QColor& bgColour, QColor& gradientColour) { osg::ref_ptr gradientRect = createGradientRectangle(bgColour, gradientColour); // Replaces previous rectangle diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index a6b0521783..228581a0ef 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -114,9 +114,9 @@ namespace CSVRender void mouseMoveEvent(QMouseEvent* event) override; void wheelEvent(QWheelEvent* event) override; - osg::ref_ptr createGradientRectangle(QColor bgColour, QColor gradientColour); - osg::ref_ptr createGradientCamera(QColor bgColour, QColor gradientColour); - void updateGradientCamera(QColor bgColour, QColor gradientColour); + osg::ref_ptr createGradientRectangle(QColor& bgColour, QColor& gradientColour); + osg::ref_ptr createGradientCamera(QColor& bgColour, QColor& gradientColour); + void updateGradientCamera(QColor& bgColour, QColor& gradientColour); std::shared_ptr mResourceSystem; diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index 407f058a15..bf56d7c70a 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -666,7 +666,7 @@ void CSVRender::TerrainTextureMode::pushEditToCommand(CSMWorld::LandTexturesColu undoStack.push(new CSMWorld::TouchLandCommand(landTable, ltexTable, cellId)); } -void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName) +void CSVRender::TerrainTextureMode::createTexture(const std::string& textureFileName) { CSMDoc::Document& document = getWorldspaceWidget().getDocument(); @@ -696,12 +696,10 @@ void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName) } while (freeIndexFound == false); std::size_t idlocation = textureFileName.find("Texture: "); - textureFileName = textureFileName.substr(idlocation + 9); - - QVariant textureNameVariant; + QString fileName = QString::fromStdString(textureFileName.substr(idlocation + 9)); QVariant textureFileNameVariant; - textureFileNameVariant.setValue(QString::fromStdString(textureFileName)); + textureFileNameVariant.setValue(fileName); undoStack.beginMacro("Add land texture record"); @@ -712,7 +710,7 @@ void CSVRender::TerrainTextureMode::createTexture(std::string textureFileName) mBrushTexture = newId; } -bool CSVRender::TerrainTextureMode::allowLandTextureEditing(std::string cellId) +bool CSVRender::TerrainTextureMode::allowLandTextureEditing(const std::string& cellId) { CSMDoc::Document& document = getWorldspaceWidget().getDocument(); CSMWorld::IdTable& landTable @@ -840,5 +838,5 @@ void CSVRender::TerrainTextureMode::setBrushShape(CSVWidget::BrushShape brushSha void CSVRender::TerrainTextureMode::setBrushTexture(std::string brushTexture) { - mBrushTexture = brushTexture; + mBrushTexture = std::move(brushTexture); } diff --git a/apps/opencs/view/render/terraintexturemode.hpp b/apps/opencs/view/render/terraintexturemode.hpp index 3fc2e3796e..c4b0b5ffd4 100644 --- a/apps/opencs/view/render/terraintexturemode.hpp +++ b/apps/opencs/view/render/terraintexturemode.hpp @@ -118,10 +118,10 @@ namespace CSVRender CSMWorld::IdTable& landTable, std::string cellId); /// \brief Create new land texture record from texture asset - void createTexture(std::string textureFileName); + void createTexture(const std::string& textureFileName); /// \brief Create new cell and land if needed - bool allowLandTextureEditing(std::string textureFileName); + bool allowLandTextureEditing(const std::string& textureFileName); std::string mCellId; std::string mBrushTexture; diff --git a/apps/opencs/view/world/nestedtable.cpp b/apps/opencs/view/world/nestedtable.cpp index 3e1b16248d..5cfdab5321 100644 --- a/apps/opencs/view/world/nestedtable.cpp +++ b/apps/opencs/view/world/nestedtable.cpp @@ -19,7 +19,7 @@ #include "tableeditidaction.hpp" #include "util.hpp" -CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, CSMWorld::UniversalId id, +CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document, const CSMWorld::UniversalId& id, CSMWorld::NestedTableProxyModel* model, QWidget* parent, bool editable, bool fixedRows) : DragRecordTable(document, parent) , mAddNewRowAction(nullptr) diff --git a/apps/opencs/view/world/nestedtable.hpp b/apps/opencs/view/world/nestedtable.hpp index 2520f45a05..07f0acdf5b 100644 --- a/apps/opencs/view/world/nestedtable.hpp +++ b/apps/opencs/view/world/nestedtable.hpp @@ -36,7 +36,7 @@ namespace CSVWorld CSMWorld::CommandDispatcher* mDispatcher; public: - NestedTable(CSMDoc::Document& document, CSMWorld::UniversalId id, CSMWorld::NestedTableProxyModel* model, + NestedTable(CSMDoc::Document& document, const CSMWorld::UniversalId& id, CSMWorld::NestedTableProxyModel* model, QWidget* parent = nullptr, bool editable = true, bool fixedRows = false); std::vector getDraggedRecords() const override; diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 0c1e1cfb98..32bd524305 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -1283,11 +1283,11 @@ namespace MWGui { } - void showPage(TypesetBook::Ptr book, size_t page) override { mPageDisplay->showPage(book, page); } + void showPage(TypesetBook::Ptr book, size_t page) override { mPageDisplay->showPage(std::move(book), page); } void adviseLinkClicked(std::function linkClicked) override { - mPageDisplay->mLinkClicked = linkClicked; + mPageDisplay->mLinkClicked = std::move(linkClicked); } void unadviseLinkClicked() override { mPageDisplay->mLinkClicked = std::function(); } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index bd7706c8b1..80e33383c2 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -52,9 +52,9 @@ namespace "Question_" + MyGUI::utility::toString(number) + "_AnswerThree") }; std::string sound = "vo\\misc\\chargen qa" + MyGUI::utility::toString(number) + ".wav"; - Response r0 = { answer0, ESM::Class::Combat }; - Response r1 = { answer1, ESM::Class::Magic }; - Response r2 = { answer2, ESM::Class::Stealth }; + Response r0 = { std::move(answer0), ESM::Class::Combat }; + Response r1 = { std::move(answer1), ESM::Class::Magic }; + Response r2 = { std::move(answer2), ESM::Class::Stealth }; // randomize order in which responses are displayed int order = Misc::Rng::rollDice(6); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 237985b204..cbd8eec82d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -328,7 +328,7 @@ namespace MWGui mHistory->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel); BookPage::ClickCallback callback = [this](TypesetBook::InteractiveId link) { notifyLinkClicked(link); }; - mHistory->adviseLinkClicked(callback); + mHistory->adviseLinkClicked(std::move(callback)); mMainWidget->castType()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); diff --git a/apps/openmw/mwgui/journalbooks.cpp b/apps/openmw/mwgui/journalbooks.cpp index f64a2ec1f0..f731744cfa 100644 --- a/apps/openmw/mwgui/journalbooks.cpp +++ b/apps/openmw/mwgui/journalbooks.cpp @@ -16,7 +16,7 @@ namespace MWGui::BookTypesetter::Style* mBodyStyle; AddContent(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style) - : mTypesetter(typesetter) + : mTypesetter(std::move(typesetter)) , mBodyStyle(body_style) { } @@ -48,7 +48,7 @@ namespace MWGui::BookTypesetter::Style* mBodyStyle; AddEntry(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style) - : mTypesetter(typesetter) + : mTypesetter(std::move(typesetter)) , mBodyStyle(body_style) { } @@ -68,7 +68,7 @@ namespace AddJournalEntry(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style, MWGui::BookTypesetter::Style* header_style, bool add_header) - : AddEntry(typesetter, body_style) + : AddEntry(std::move(typesetter), body_style) , mAddHeader(add_header) , mHeaderStyle(header_style) { @@ -95,7 +95,7 @@ namespace AddTopicEntry(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* body_style, MWGui::BookTypesetter::Style* header_style, intptr_t contentId) - : AddEntry(typesetter, body_style) + : AddEntry(std::move(typesetter), body_style) , mContentId(contentId) , mHeaderStyle(header_style) { @@ -118,7 +118,7 @@ namespace struct AddTopicName : AddContent { AddTopicName(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) - : AddContent(typesetter, style) + : AddContent(std::move(typesetter), style) { } @@ -132,7 +132,7 @@ namespace struct AddQuestName : AddContent { AddQuestName(MWGui::BookTypesetter::Ptr typesetter, MWGui::BookTypesetter::Style* style) - : AddContent(typesetter, style) + : AddContent(std::move(typesetter), style) { } diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 46adcd977e..8265615b65 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -91,8 +91,8 @@ namespace MWGui::BookPage* getPage(std::string_view name) { return getWidget(name); } - JournalWindowImpl(MWGui::JournalViewModel::Ptr Model, bool questList, ToUTF8::FromType encoding) - : JournalBooks(Model, encoding) + JournalWindowImpl(MWGui::JournalViewModel::Ptr model, bool questList, ToUTF8::FromType encoding) + : JournalBooks(std::move(model), encoding) , JournalWindow() { center(); @@ -313,7 +313,7 @@ namespace notifyTopics(getWidget(TopicsList)); } - void pushBook(Book book, unsigned int page) + void pushBook(Book& book, unsigned int page) { DisplayState bs; bs.mPage = page; @@ -323,7 +323,7 @@ namespace updateCloseJournalButton(); } - void replaceBook(Book book, unsigned int page) + void replaceBook(Book& book, unsigned int page) { assert(!mStates.empty()); mStates.top().mBook = book; diff --git a/apps/openmw/mwgui/journalwindow.hpp b/apps/openmw/mwgui/journalwindow.hpp index 1c73e37a34..6e037a3989 100644 --- a/apps/openmw/mwgui/journalwindow.hpp +++ b/apps/openmw/mwgui/journalwindow.hpp @@ -22,7 +22,7 @@ namespace MWGui /// construct a new instance of the one JournalWindow implementation static std::unique_ptr create( - std::shared_ptr Model, bool questList, ToUTF8::FromType encoding); + std::shared_ptr model, bool questList, ToUTF8::FromType encoding); /// destroy this instance of the JournalWindow implementation virtual ~JournalWindow() {} diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index fbd72227e6..19ff8229e3 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -500,7 +500,7 @@ namespace MWGui std::pair widgets = addValueItem(skill->mName, {}, "normal", coord1, coord2); - mSkillWidgetMap[skill->mId] = widgets; + mSkillWidgetMap[skill->mId] = std::move(widgets); for (int i = 0; i < 2; ++i) { diff --git a/apps/openmw/mwlua/types/types.hpp b/apps/openmw/mwlua/types/types.hpp index 9f179a78e3..a77f9d3219 100644 --- a/apps/openmw/mwlua/types/types.hpp +++ b/apps/openmw/mwlua/types/types.hpp @@ -71,7 +71,7 @@ namespace MWLua template void addRecordFunctionBinding( - sol::table table, const Context& context, const std::string& recordName = std::string(T::getRecordType())) + sol::table& table, const Context& context, const std::string& recordName = std::string(T::getRecordType())) { const MWWorld::Store& store = MWBase::Environment::get().getESMStore()->get(); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 045f13a714..8615811cc3 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -172,7 +172,7 @@ namespace MWRender std::shared_ptr mTimePtr; public: - void setTimePtr(std::shared_ptr time) { mTimePtr = time; } + void setTimePtr(std::shared_ptr time) { mTimePtr = std::move(time); } std::shared_ptr getTimePtr() const { return mTimePtr; } float getValue(osg::NodeVisitor* nv) override; diff --git a/apps/openmw/mwrender/luminancecalculator.cpp b/apps/openmw/mwrender/luminancecalculator.cpp index e0d275b177..53240205c7 100644 --- a/apps/openmw/mwrender/luminancecalculator.cpp +++ b/apps/openmw/mwrender/luminancecalculator.cpp @@ -21,8 +21,8 @@ namespace MWRender auto luminanceFragment = shaderManager.getShader("luminance/luminance.frag", defines); auto resolveFragment = shaderManager.getShader("luminance/resolve.frag", defines); - mResolveProgram = shaderManager.getProgram(vertex, resolveFragment); - mLuminanceProgram = shaderManager.getProgram(vertex, luminanceFragment); + mResolveProgram = shaderManager.getProgram(vertex, std::move(resolveFragment)); + mLuminanceProgram = shaderManager.getProgram(vertex, std::move(luminanceFragment)); } void LuminanceCalculator::compile() @@ -150,4 +150,4 @@ namespace MWRender mCompiled = false; } -} \ No newline at end of file +} diff --git a/apps/openmw/mwrender/navmesh.cpp b/apps/openmw/mwrender/navmesh.cpp index bb4a2aa234..8d638c918b 100644 --- a/apps/openmw/mwrender/navmesh.cpp +++ b/apps/openmw/mwrender/navmesh.cpp @@ -60,7 +60,7 @@ namespace MWRender NavMeshMode mode) : mId(id) , mVersion(version) - , mNavMesh(navMesh) + , mNavMesh(std::move(navMesh)) , mGroupStateSet(groupStateSet) , mDebugDrawStateSet(debugDrawStateSet) , mSettings(settings) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index c7ad14013b..bced5820fa 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -63,7 +63,7 @@ namespace MWWorld public: ResolutionHandle(std::shared_ptr listener) - : mListener(listener) + : mListener(std::move(listener)) { } ResolutionHandle() = default; diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 970b8aa0fa..fa76f77f02 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -10,7 +10,7 @@ #include #include -ContentSelectorModel::ContentModel::ContentModel(QObject* parent, QIcon warningIcon, bool showOMWScripts) +ContentSelectorModel::ContentModel::ContentModel(QObject* parent, QIcon& warningIcon, bool showOMWScripts) : QAbstractTableModel(parent) , mWarningIcon(warningIcon) , mShowOMWScripts(showOMWScripts) diff --git a/components/contentselector/model/contentmodel.hpp b/components/contentselector/model/contentmodel.hpp index 09fed11519..f5924ecccf 100644 --- a/components/contentselector/model/contentmodel.hpp +++ b/components/contentselector/model/contentmodel.hpp @@ -23,7 +23,7 @@ namespace ContentSelectorModel { Q_OBJECT public: - explicit ContentModel(QObject* parent, QIcon warningIcon, bool showOMWScripts); + explicit ContentModel(QObject* parent, QIcon& warningIcon, bool showOMWScripts); ~ContentModel(); void setEncoding(const QString& encoding); diff --git a/components/contentselector/model/esmfile.cpp b/components/contentselector/model/esmfile.cpp index d11d2023de..741ed173a2 100644 --- a/components/contentselector/model/esmfile.cpp +++ b/components/contentselector/model/esmfile.cpp @@ -12,7 +12,7 @@ QString ContentSelectorModel::EsmFile::sToolTip = QString(
Description:
%5
\
Dependencies: %6
"); -ContentSelectorModel::EsmFile::EsmFile(QString fileName, ModelItem* parent) +ContentSelectorModel::EsmFile::EsmFile(const QString& fileName, ModelItem* parent) : ModelItem(parent) , mFileName(fileName) { diff --git a/components/contentselector/model/esmfile.hpp b/components/contentselector/model/esmfile.hpp index f51c6cfca2..1ffaa8fe72 100644 --- a/components/contentselector/model/esmfile.hpp +++ b/components/contentselector/model/esmfile.hpp @@ -29,7 +29,7 @@ namespace ContentSelectorModel FileProperty_GameFile = 6 }; - EsmFile(QString fileName = QString(), ModelItem* parent = nullptr); + EsmFile(const QString& fileName = QString(), ModelItem* parent = nullptr); // EsmFile(const EsmFile &); ~EsmFile() {} diff --git a/components/contentselector/model/loadordererror.hpp b/components/contentselector/model/loadordererror.hpp index d33005827d..8f47b6ed6a 100644 --- a/components/contentselector/model/loadordererror.hpp +++ b/components/contentselector/model/loadordererror.hpp @@ -21,7 +21,7 @@ namespace ContentSelectorModel : mErrorCode(ErrorCode_None) { } - inline LoadOrderError(ErrorCode errorCode, QString fileName) + inline LoadOrderError(ErrorCode errorCode, const QString& fileName) : mErrorCode(errorCode) , mFileName(fileName) { diff --git a/components/esm3/transport.cpp b/components/esm3/transport.cpp index aacbbe5a52..8b131b1b5f 100644 --- a/components/esm3/transport.cpp +++ b/components/esm3/transport.cpp @@ -22,7 +22,7 @@ namespace ESM if (mList.empty()) Log(Debug::Warning) << "Encountered DNAM record without DODT record, skipped."; else - mList.back().mCellName = name; + mList.back().mCellName = std::move(name); } } diff --git a/components/fallback/validate.cpp b/components/fallback/validate.cpp index b8a4bcca22..ca9a218888 100644 --- a/components/fallback/validate.cpp +++ b/components/fallback/validate.cpp @@ -264,6 +264,6 @@ void Fallback::validate(boost::any& v, std::vector const& tokens, F std::string key(token.substr(0, sep)); std::string value(token.substr(sep + 1)); - map->mMap[key] = value; + map->mMap[key] = std::move(value); } } diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index 6016daca64..e69712cca5 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -408,7 +408,7 @@ namespace Gui file.reset(); // Create the font texture - std::string bitmapFilename = "fonts/" + std::string(name) + ".tex"; + std::string bitmapFilename = "fonts/" + std::move(name) + ".tex"; Files::IStreamPtr bitmapFile = mVFS->get(bitmapFilename); diff --git a/components/fx/stateupdater.hpp b/components/fx/stateupdater.hpp index 0fb02da093..c4bf71642c 100644 --- a/components/fx/stateupdater.hpp +++ b/components/fx/stateupdater.hpp @@ -95,7 +95,10 @@ namespace fx mData.get() = transition > 0 ? 1 - transition : 0; } - void bindPointLights(std::shared_ptr buffer) { mPointLightBuffer = buffer; } + void bindPointLights(std::shared_ptr buffer) + { + mPointLightBuffer = std::move(buffer); + } static std::string getStructDefinition() { diff --git a/components/sceneutil/controller.cpp b/components/sceneutil/controller.cpp index e416d589bf..e44c02741a 100644 --- a/components/sceneutil/controller.cpp +++ b/components/sceneutil/controller.cpp @@ -29,12 +29,12 @@ namespace SceneUtil void Controller::setSource(std::shared_ptr source) { - mSource = source; + mSource = std::move(source); } void Controller::setFunction(std::shared_ptr function) { - mFunction = function; + mFunction = std::move(function); } std::shared_ptr Controller::getSource() const @@ -105,7 +105,7 @@ namespace SceneUtil AssignControllerSourcesVisitor::AssignControllerSourcesVisitor(std::shared_ptr toAssign) : ControllerVisitor() - , mToAssign(toAssign) + , mToAssign(std::move(toAssign)) { } @@ -121,7 +121,7 @@ namespace SceneUtil } ForceControllerSourcesVisitor::ForceControllerSourcesVisitor(std::shared_ptr toAssign) - : AssignControllerSourcesVisitor(toAssign) + : AssignControllerSourcesVisitor(std::move(toAssign)) { } diff --git a/components/sceneutil/riggeometryosgaextension.cpp b/components/sceneutil/riggeometryosgaextension.cpp index 4c6cd10c08..8878c38067 100644 --- a/components/sceneutil/riggeometryosgaextension.cpp +++ b/components/sceneutil/riggeometryosgaextension.cpp @@ -192,7 +192,7 @@ namespace SceneUtil } osg::MatrixList mtxList = root->getWorldMatrices(root); // We always assume that RigGeometries have origin at their root - geom->computeMatrixFromRootSkeleton(mtxList); + geom->computeMatrixFromRootSkeleton(std::move(mtxList)); if (mIsBodyPart && mBackToOrigin) updateBackToOriginTransform(geom); diff --git a/components/sceneutil/screencapture.cpp b/components/sceneutil/screencapture.cpp index 439686a04d..8382e75e54 100644 --- a/components/sceneutil/screencapture.cpp +++ b/components/sceneutil/screencapture.cpp @@ -105,7 +105,7 @@ namespace SceneUtil const std::string& screenshotFormat, std::function callback) : mScreenshotPath(screenshotPath) , mScreenshotFormat(screenshotFormat) - , mCallback(callback) + , mCallback(std::move(callback)) { } diff --git a/components/stereo/stereomanager.cpp b/components/stereo/stereomanager.cpp index 48e7ee11a9..bf82d52078 100644 --- a/components/stereo/stereomanager.cpp +++ b/components/stereo/stereomanager.cpp @@ -348,7 +348,7 @@ namespace Stereo void Manager::setUpdateViewCallback(std::shared_ptr cb) { - mUpdateViewCallback = cb; + mUpdateViewCallback = std::move(cb); } void Manager::setCullCallback(osg::ref_ptr cb) @@ -382,7 +382,7 @@ namespace Stereo return sStereoEnabled; } - Manager::CustomViewCallback::CustomViewCallback(View left, View right) + Manager::CustomViewCallback::CustomViewCallback(View& left, View& right) : mLeft(left) , mRight(right) { diff --git a/components/stereo/stereomanager.hpp b/components/stereo/stereomanager.hpp index f9bf83f184..6f4e971718 100644 --- a/components/stereo/stereomanager.hpp +++ b/components/stereo/stereomanager.hpp @@ -59,7 +59,7 @@ namespace Stereo struct CustomViewCallback : public UpdateViewCallback { public: - CustomViewCallback(View left, View right); + CustomViewCallback(View& left, View& right); void updateView(View& left, View& right) override;