Skip to content

Commit e75fb44

Browse files
committed
refactor(perf): rename move_assign_from_pointer to move_or_swap and change parameter to reference
1 parent 63ff05f commit e75fb44

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Dependencies/Utility/Utility/CppMacros.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
#define nullptr 0
5050
#endif
5151

52-
// TheSuperHackers @performance bobtista 25/11/2025 Helper to move-assign from pointer: uses std::move in C++11, swap in C++98
52+
// TheSuperHackers @performance bobtista 25/11/2025 Helper to move-assign from reference: uses std::move in C++11, swap in C++98
5353
template<typename T>
54-
inline void move_assign_from_pointer(T& dest, T* src)
54+
inline void move_or_swap(T& dest, T& src)
5555
{
5656
#if __cplusplus >= 201103L
57-
dest = std::move(*src);
57+
dest = std::move(src);
5858
#else
5959
// Use swap to emulate move semantics for VC6 compatibility
60-
dest.swap(*src);
60+
dest.swap(src);
6161
#endif
6262
}

Generals/Code/GameEngine/Include/GameLogic/AI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,15 @@ class AICommandInterface
539539
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
540540
{
541541
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
542-
move_assign_from_pointer(parms.m_coords, path);
542+
move_or_swap(parms.m_coords, *path);
543543
parms.m_obj = ignoreObject;
544544
aiDoCommand(&parms);
545545
}
546546

547547
inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
548548
{
549549
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
550-
move_assign_from_pointer(parms.m_coords, path);
550+
move_or_swap(parms.m_coords, *path);
551551
parms.m_obj = ignoreObject;
552552
aiDoCommand(&parms);
553553
}

Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ void AIStateMachine::loadPostProcess( void )
818818
*/
819819
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
820820
{
821-
move_assign_from_pointer(m_goalPath, path);
821+
move_or_swap(m_goalPath, *path);
822822
}
823823

824824
#ifdef STATE_MACHINE_DEBUG

GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,15 @@ class AICommandInterface
553553
inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
554554
{
555555
AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
556-
move_assign_from_pointer(parms.m_coords, path);
556+
move_or_swap(parms.m_coords, *path);
557557
parms.m_obj = ignoreObject;
558558
aiDoCommand(&parms);
559559
}
560560

561561
inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
562562
{
563563
AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
564-
move_assign_from_pointer(parms.m_coords, path);
564+
move_or_swap(parms.m_coords, *path);
565565
parms.m_obj = ignoreObject;
566566
aiDoCommand(&parms);
567567
}

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ void AIStateMachine::loadPostProcess( void )
823823
*/
824824
void AIStateMachine::setGoalPath( std::vector<Coord3D>* path )
825825
{
826-
move_assign_from_pointer(m_goalPath, path);
826+
move_or_swap(m_goalPath, *path);
827827
}
828828

829829
#ifdef STATE_MACHINE_DEBUG

0 commit comments

Comments
 (0)