Skip to content

Commit

Permalink
Merge branch 'avoid_copies' into 'master'
Browse files Browse the repository at this point in the history
Avoid redundant copies

See merge request OpenMW/openmw!3637
  • Loading branch information
Capostrophic committed Dec 7, 2023
2 parents b67d89f + 6f68df9 commit 571a097
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions apps/bulletobjecttool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ namespace

config.filterOutNonExistingPaths(dataDirs);

const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
const auto& resDir = variables["resources"].as<Files::MaybeQuotedPath>();
Log(Debug::Info) << Version::getOpenmwVersionDescription();
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
const auto fileCollections = Files::Collections(dataDirs);
const auto archives = variables["fallback-archive"].as<StringsVector>();
const auto contentFiles = variables["content"].as<StringsVector>();
const Files::Collections fileCollections(dataDirs);
const auto& archives = variables["fallback-archive"].as<StringsVector>();
const auto& contentFiles = variables["content"].as<StringsVector>();

Fallback::Map::init(variables["fallback"].as<Fallback::FallbackMap>().mMap);

Expand Down
2 changes: 1 addition & 1 deletion apps/esmtool/esmtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Allowed options)");
return false;
}*/

const auto inputFiles = variables["input-file"].as<Files::MaybeQuotedPathContainer>();
const auto& inputFiles = variables["input-file"].as<Files::MaybeQuotedPathContainer>();
info.filename = inputFiles[0].u8string(); // This call to u8string is redundant, but required to build on
// MSVC 14.26 due to implementation bugs.
if (inputFiles.size() > 1)
Expand Down
4 changes: 2 additions & 2 deletions apps/essimporter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Allowed options)");
Files::ConfigurationManager cfgManager(true);
cfgManager.readConfiguration(variables, desc);

const auto essFile = variables["mwsave"].as<Files::MaybeQuotedPath>();
const auto outputFile = variables["output"].as<Files::MaybeQuotedPath>();
const auto& essFile = variables["mwsave"].as<Files::MaybeQuotedPath>();
const auto& outputFile = variables["output"].as<Files::MaybeQuotedPath>();
std::string encoding = variables["encoding"].as<std::string>();

ESSImport::Importer importer(essFile, outputFile, encoding);
Expand Down
8 changes: 4 additions & 4 deletions apps/navmeshtool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ namespace NavMeshTool

config.filterOutNonExistingPaths(dataDirs);

const auto resDir = variables["resources"].as<Files::MaybeQuotedPath>();
const auto& resDir = variables["resources"].as<Files::MaybeQuotedPath>();
Log(Debug::Info) << Version::getOpenmwVersionDescription();
dataDirs.insert(dataDirs.begin(), resDir / "vfs");
const auto fileCollections = Files::Collections(dataDirs);
const auto archives = variables["fallback-archive"].as<StringsVector>();
const auto contentFiles = variables["content"].as<StringsVector>();
const Files::Collections fileCollections(dataDirs);
const auto& archives = variables["fallback-archive"].as<StringsVector>();
const auto& contentFiles = variables["content"].as<StringsVector>();
const std::size_t threadsNumber = variables["threads"].as<std::size_t>();

if (threadsNumber < 1)
Expand Down
2 changes: 1 addition & 1 deletion apps/opencs/view/world/dragrecordtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void CSVWorld::DragRecordTable::dropEvent(QDropEvent* event)
if (CSVWorld::DragDropUtils::isTopicOrJournal(*event, display))
{
const CSMWorld::TableMimeData* tableMimeData = CSVWorld::DragDropUtils::getTableMimeData(*event);
for (auto universalId : tableMimeData->getData())
for (const auto& universalId : tableMimeData->getData())
{
emit createNewInfoRecord(universalId.getId());
}
Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/mwlua/magicbindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ namespace MWLua

// Note that, although this is member method of ActorActiveEffects and we are removing an effect (not a
// spell), we still need to use the active spells store to purge this effect from active spells.
auto ptr = effects.mActor.ptr();
const auto& ptr = effects.mActor.ptr();

auto& activeSpells = ptr.getClass().getCreatureStats(ptr).getActiveSpells();
activeSpells.purgeEffect(ptr, key.mId, key.mArg);
Expand Down
4 changes: 2 additions & 2 deletions apps/openmw/mwworld/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ namespace

osg::Quat makeInverseNodeRotation(const MWWorld::Ptr& ptr)
{
const auto pos = ptr.getRefData().getPosition();
const auto& pos = ptr.getRefData().getPosition();
return ptr.getClass().isActor() ? makeActorOsgQuat(pos) : makeInversedOrderObjectOsgQuat(pos);
}

osg::Quat makeDirectNodeRotation(const MWWorld::Ptr& ptr)
{
const auto pos = ptr.getRefData().getPosition();
const auto& pos = ptr.getRefData().getPosition();
return ptr.getClass().isActor() ? makeActorOsgQuat(pos) : Misc::Convert::makeOsgQuat(pos);
}

Expand Down

0 comments on commit 571a097

Please sign in to comment.