Skip to content

Commit 679982d

Browse files
committed
Optimized std::map key for performance.
1 parent 91d3ea8 commit 679982d

11 files changed

+288
-262
lines changed

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class CClientGame
508508
static CAnimBlendAssociationSAInterface * StaticAddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
509509
static CAnimBlendAssociationSAInterface * StaticAddAnimationAndSyncHandler( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID );
510510
static bool StaticAssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, CAnimBlendAssociationSAInterface * pAnimAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID );
511-
static bool StaticBlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump );
511+
static bool StaticBlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, int * pFlags, RpClump * pClump );
512512
static bool StaticProcessCollisionHandler ( CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface );
513513
static bool StaticVehicleCollisionHandler ( CVehicleSAInterface* pThisInterface, CEntitySAInterface* pOtherInterface, int iModelIndex, float fDamageImpulseMag, float fCollidingDamageImpulseMag, uint16 usPieceType, CVector vecCollisionPos, CVector vecCollisionVelocity );
514514
static bool StaticVehicleDamageHandler ( CEntitySAInterface* pVehicleInterface, float fLoss, CEntitySAInterface* pAttackerInterface, eWeaponType weaponType, const CVector& vecDamagePos, uchar ucTyre );
@@ -542,7 +542,7 @@ class CClientGame
542542
CAnimBlendAssociationSAInterface * AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
543543
CAnimBlendAssociationSAInterface * AddAnimationAndSyncHandler ( RpClump * pClump, CAnimBlendAssociationSAInterface * pAnimAssocToSyncWith, AssocGroupId animGroup, AnimationId animID );
544544
bool AssocGroupCopyAnimationHandler ( CAnimBlendStaticAssociationSAInterface * pOutAnimStaticAssoc, CAnimBlendAssociationSAInterface * pAnimAssoc, RpClump * pClump, CAnimBlendAssocGroupSAInterface * pAnimAssocGroup, AnimationId animID );
545-
bool BlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, RpClump * pClump );
545+
bool BlendAnimationHierarchyHandler ( CAnimBlendAssociationSAInterface * pAnimAssoc, CAnimBlendHierarchySAInterface ** pOutAnimHierarchy, int * pFlags, RpClump * pClump );
546546
bool ProcessCollisionHandler ( CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface );
547547
bool VehicleCollisionHandler ( CVehicleSAInterface* pCollidingVehicle, CEntitySAInterface* pCollidedVehicle, int iModelIndex, float fDamageImpulseMag, float fCollidingDamageImpulseMag, uint16 usPieceType, CVector vecCollisionPos, CVector vecCollisionVelocity );
548548
bool VehicleDamageHandler ( CEntitySAInterface* pVehicleInterface, float fLoss, CEntitySAInterface* pAttackerInterface, eWeaponType weaponType, const CVector& vecDamagePos, uchar ucTyre );
@@ -593,12 +593,12 @@ class CClientGame
593593
void SetFileCacheRoot ( void );
594594
const char* GetFileCacheRoot ( void ) { return m_strFileCacheRoot; }
595595

596-
void InsertIFPPointerToMap ( const SString & strBlockName, const std::shared_ptr < CClientIFP > & pIFP );
597-
void RemoveIFPPointerFromMap ( const SString & strBlockName );
598-
std::shared_ptr < CClientIFP > GetIFPPointerFromMap ( const SString & strBlockName );
596+
inline void InsertIFPPointerToMap ( const unsigned int u32BlockNameHash, const std::shared_ptr < CClientIFP > & pIFP ) { m_mapOfIfpPointers [ u32BlockNameHash ] = pIFP; }
597+
inline void RemoveIFPPointerFromMap ( const unsigned int u32BlockNameHash ) { m_mapOfIfpPointers.erase ( u32BlockNameHash ); }
598+
std::shared_ptr < CClientIFP > GetIFPPointerFromMap ( const unsigned int u32BlockNameHash );
599599

600-
void InsertPedPointerToMap ( CClientPed * pPed );
601-
void RemovePedPointerFromMap ( CClientPed * pPed );
600+
void InsertPedPointerToMap ( CClientPed * pPed ) { m_mapOfPedPointers [ pPed ] = true; }
601+
void RemovePedPointerFromMap ( CClientPed * pPed ) { m_mapOfPedPointers.erase ( pPed ); }
602602
CClientPed * GetClientPedByClump ( const RpClump & Clump );
603603

604604
void OnClientIFPUnload ( const std::shared_ptr < CClientIFP > & IFP );
@@ -819,8 +819,8 @@ class CClientGame
819819

820820
SharedUtil::CAsyncTaskScheduler* m_pAsyncTaskScheduler;
821821

822-
// (SString) Key is custom block name that is supplied to engineLoadIFP
823-
std::map < SString, std::shared_ptr < CClientIFP > > m_mapOfIfpPointers;
822+
// (unsigned int) Key is the hash of custom block name that is supplied to engineLoadIFP
823+
std::map < unsigned int, std::shared_ptr < CClientIFP > > m_mapOfIfpPointers;
824824

825825
std::map < CClientPed *, bool > m_mapOfPedPointers;
826826
AnimAssociations_type m_mapOfCustomAnimationAssociations;

0 commit comments

Comments
 (0)