1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Use std::swap

This commit is contained in:
2014-07-22 22:34:43 -07:00
parent 72f18e8ebb
commit 1a987173d6
5 changed files with 6 additions and 42 deletions

View File

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

View File

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

View File

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

View File

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

View File

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