Browse Source

Use std::swap

Michael Hansen 11 years ago
parent
commit
1a987173d6
  1. 36
      Sources/Plasma/CoreLib/HeadSpin.h
  2. 6
      Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h
  3. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  4. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

36
Sources/Plasma/CoreLib/HeadSpin.h

@ -212,27 +212,6 @@ inline double hsSwapEndianDouble(double dvalue)
#define hsToLEDouble(n) hsSwapEndianDouble(n) #define hsToLEDouble(n) hsSwapEndianDouble(n)
#endif #endif
inline void hsSwap(int32_t& a, int32_t& b)
{
int32_t c = a;
a = b;
b = c;
}
inline void hsSwap(uint32_t& a, uint32_t& b)
{
uint32_t c = a;
a = b;
b = c;
}
inline void hsSwap(float& a, float& b)
{
float c = a;
a = b;
b = c;
}
//=========================================================================== //===========================================================================
// Define a NOOP (null) statement // Define a NOOP (null) statement
//=========================================================================== //===========================================================================
@ -242,21 +221,6 @@ inline void hsSwap(float& a, float& b)
# define NULL_STMT ((void)0) # define NULL_STMT ((void)0)
#endif #endif
/****************************************************************************
*
* SWAP
* Swaps the values of two variables
*
***/
//===========================================================================
template<class T>
void SWAP (T & a, T & b) {
T temp = a;
a = b;
b = temp;
}
/**************************************************************************** /****************************************************************************
* *

6
Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h

@ -97,7 +97,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
T * mid = lo + (hi - lo) / 2; \ T * mid = lo + (hi - lo) / 2; \
\ \
/* Swap it to the beginning of the array */ \ /* Swap it to the beginning of the array */ \
SWAP(*mid, *lo); \ std::swap(*mid, *lo); \
\ \
/* Partition the array into three pieces, one consisting of */ \ /* Partition the array into three pieces, one consisting of */ \
/* elements <= the partitioning element, one of elements */ \ /* elements <= the partitioning element, one of elements */ \
@ -134,7 +134,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/* val(loPart) > val(lo) */ \ /* val(loPart) > val(lo) */ \
/* val(hiPart) < val(lo) */ \ /* val(hiPart) < val(lo) */ \
\ \
SWAP(*loPart, *hiPart); \ std::swap(*loPart, *hiPart); \
\ \
/* val(loPart) < val(lo) */ \ /* val(loPart) < val(lo) */ \
/* val(hiPart) > val(lo) */ \ /* val(hiPart) > val(lo) */ \
@ -145,7 +145,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/* val(i) >= val(lo) for loPart <= i <= hi */ \ /* val(i) >= val(lo) for loPart <= i <= hi */ \
\ \
/* Put the partitioning element in place */ \ /* Put the partitioning element in place */ \
SWAP(*lo, *hiPart); \ std::swap(*lo, *hiPart); \
\ \
/* val(i) <= val(hiPart) for lo <= i < hiPart */ \ /* val(i) <= val(hiPart) for lo <= i < hiPart */ \
/* val(i) == val(lo) for hiPart <= i < loPart */ \ /* val(i) == val(lo) for hiPart <= i < loPart */ \

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -760,7 +760,7 @@ void CliFileConn::Destroy () {
{ {
hsLockForWriting lock(sockLock); hsLockForWriting lock(sockLock);
SWAP(oldSock, sock); std::swap(oldSock, sock);
} }
if (oldSock) if (oldSock)

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp

@ -218,7 +218,7 @@ static bool ConnEncrypt (ENetError error, void * param) {
if (IS_NET_SUCCESS(error)) { if (IS_NET_SUCCESS(error)) {
s_critsect.Enter(); s_critsect.Enter();
{ {
SWAP(s_active, conn); std::swap(s_active, conn);
} }
s_critsect.Leave(); s_critsect.Leave();
} }

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

@ -267,7 +267,7 @@ static bool ConnEncrypt (ENetError error, void * param) {
s_critsect.Enter(); s_critsect.Enter();
{ {
SWAP(s_active, conn); std::swap(s_active, conn);
} }
s_critsect.Leave(); s_critsect.Leave();

Loading…
Cancel
Save