From 6fb7af3b631db8e806cf1837136f3b39a91d65fd Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 6 Jul 2022 14:21:53 +0200 Subject: [PATCH] Avoid redundant copy when finding item in NavMeshTilesCache std::make_tuple returns a tuple for types with removed references which makes it to copy arguments. std::tie leaves references. --- components/detournavigator/navmeshtilescache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/detournavigator/navmeshtilescache.cpp b/components/detournavigator/navmeshtilescache.cpp index 6938ff3650..a07aa873c4 100644 --- a/components/detournavigator/navmeshtilescache.cpp +++ b/components/detournavigator/navmeshtilescache.cpp @@ -17,7 +17,7 @@ namespace DetourNavigator ++mGetCount; - const auto tile = mValues.find(std::make_tuple(agentBounds, changedTile, recastMesh)); + const auto tile = mValues.find(std::tie(agentBounds, changedTile, recastMesh)); if (tile == mValues.end()) return Value(); @@ -92,7 +92,7 @@ namespace DetourNavigator { const auto& item = mFreeItems.back(); - const auto value = mValues.find(std::make_tuple(item.mAgentBounds, item.mChangedTile, std::cref(item.mRecastMeshData))); + const auto value = mValues.find(std::tie(item.mAgentBounds, item.mChangedTile, item.mRecastMeshData)); if (value == mValues.end()) return;