From 2ce2741968e861d10acfe1e7b012ec2448accdc7 Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Fri, 16 Jan 2015 18:42:19 +0300 Subject: Fixed CppCheck: (performance) Function parameter should be passed by reference. --- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index fad0a36d2..6fb9a5acb 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -771,7 +771,7 @@ bool cPluginManager::CallHookPlayerFoodLevelChange(cPlayer & a_Player, int a_New -bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward) +bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems & a_Reward) { FIND_HOOK(HOOK_PLAYER_FISHED); VERIFY_HOOK; @@ -847,7 +847,7 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i -bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player, const Vector3d a_OldPosition, const Vector3d a_NewPosition) +bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition) { FIND_HOOK(HOOK_PLAYER_MOVING); VERIFY_HOOK; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index d4b82376a..576430964 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -203,12 +203,12 @@ public: bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerDestroyed (cPlayer & a_Player); bool CallHookPlayerEating (cPlayer & a_Player); - bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward); + bool CallHookPlayerFished (cPlayer & a_Player, const cItems & a_Reward); bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); bool CallHookPlayerFoodLevelChange (cPlayer & a_Player, int a_NewFoodLevel); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); - bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d a_OldPosition, const Vector3d a_NewPosition); + bool CallHookPlayerMoving (cPlayer & a_Player, const Vector3d & a_OldPosition, const Vector3d & a_NewPosition); bool CallHookPlayerPlacedBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange); bool CallHookPlayerPlacingBlock (cPlayer & a_Player, const sSetBlock & a_BlockChange); bool CallHookPlayerRightClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); -- cgit v1.2.3 From 3dc994f9dca109c0d039d6ba39480eaf67d7cc57 Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Sat, 17 Jan 2015 15:12:14 +0300 Subject: Fixed CppCheck: (performance) Possible inefficient checking for emptiness. --- src/LightingThread.cpp | 2 +- src/MobProximityCounter.cpp | 2 +- src/OSSupport/Queue.h | 4 ++-- src/Server.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index ced95d4e1..effde03d0 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -197,7 +197,7 @@ void cLightingThread::Execute(void) { { cCSLock Lock(m_CS); - if (m_Queue.size() == 0) + if (m_Queue.empty()) { cCSUnlock Unlock(Lock); m_evtItemAdded.Wait(); diff --git a/src/MobProximityCounter.cpp b/src/MobProximityCounter.cpp index 82ba771ff..cfd52440b 100644 --- a/src/MobProximityCounter.cpp +++ b/src/MobProximityCounter.cpp @@ -50,7 +50,7 @@ cMobProximityCounter::sIterablePair cMobProximityCounter::getMobWithinThosesDist a_DistanceMin *= a_DistanceMin;// this is because is use square distance a_DistanceMax *= a_DistanceMax; - if (m_DistanceToMonster.size() <= 0) + if (m_DistanceToMonster.empty()) { convertMaps(); } diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 82f221453..afbde1b0d 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -86,7 +86,7 @@ public: bool TryDequeueItem(ItemType & item) { cCSLock Lock(m_CS); - if (m_Contents.size() == 0) + if (m_Contents.empty()) { return false; } @@ -101,7 +101,7 @@ public: ItemType DequeueItem(void) { cCSLock Lock(m_CS); - while (m_Contents.size() == 0) + while (m_Contents.empty()) { cCSUnlock Unlock(Lock); m_evtAdded.Wait(); diff --git a/src/Server.cpp b/src/Server.cpp index 3eaf6e096..4dbe59ac6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -764,7 +764,7 @@ void cServer::cNotifyWriteThread::Execute(void) while (!m_ShouldTerminate) { cCSLock Lock(m_CS); - while (m_Clients.size() == 0) + while (m_Clients.empty()) { cCSUnlock Unlock(Lock); m_Event.Wait(); -- cgit v1.2.3 From 41f30edcf77521630b7f69d3e94338e6ab2f821f Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Sat, 17 Jan 2015 16:00:12 +0300 Subject: Fixed CppCheck: (performance) Prefer prefix ++/-- operators for non-primitive types. --- src/Root.cpp | 2 +- src/SetChunkData.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Root.cpp b/src/Root.cpp index 8951bafe6..eaacf3608 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -639,7 +639,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac bool cRoot::DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback) { - for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end();itr++) + for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr) { if (itr->second->DoWithPlayerByUUID(a_PlayerUUID, a_Callback)) { diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp index e335176a8..5a0bea980 100644 --- a/src/SetChunkData.cpp +++ b/src/SetChunkData.cpp @@ -132,7 +132,7 @@ void cSetChunkData::RemoveInvalidBlockEntities(void) ItemTypeToString(WorldBlockType).c_str(), WorldBlockType ); cBlockEntityList::iterator itr2 = itr; - itr2++; + ++itr2; delete *itr; m_BlockEntities.erase(itr); itr = itr2; -- cgit v1.2.3