Skip to content

Commit

Permalink
COMMON: Replace SWAP with std::swap
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 committed Aug 13, 2020
1 parent 3d18e58 commit 96fac63
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/aurora/locstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool LocString::empty() const {
}

void LocString::swap(LocString &str) {
SWAP(_id, str._id);
std::swap(_id, str._id);

_strings.swap(str._strings);
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/blowfish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ static void blowfishEnc(BlowfishContext &ctx, uint32 &xl, uint32 &xr) {
xl = xl ^ ctx.P[i];
xr = F(ctx, xl) ^ xr;

SWAP(xl, xr);
std::swap(xl, xr);
}

SWAP(xl, xr);
std::swap(xl, xr);

xr = xr ^ ctx.P[kRoundCount];
xl = xl ^ ctx.P[kRoundCount + 1];
Expand All @@ -264,10 +264,10 @@ static void blowfishDec(BlowfishContext &ctx, uint32 &xl, uint32 &xr) {
xl = xl ^ ctx.P[i];
xr = F(ctx, xl) ^ xr;

SWAP(xl, xr);
std::swap(xl, xr);
}

SWAP(xl, xr);
std::swap(xl, xr);

xr = xr ^ ctx.P[1];
xl = xl ^ ctx.P[0];
Expand Down
2 changes: 1 addition & 1 deletion src/common/fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void FFT::permute(Complex *z) {
int k = _revTab[j];

if (k < j)
SWAP(z[k], z[j]);
std::swap(z[k], z[j]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ bool UString::lessIgnoreCase(const UString &str) const {
void UString::swap(UString &str) {
_string.swap(str._string);

SWAP(_size, str._size);
std::swap(_size, str._size);
}

void UString::clear() {
Expand Down
5 changes: 0 additions & 5 deletions src/common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ template<typename T> inline T MAX (T a, T b) { return (a>b) ? a : b; }
template<typename T> inline T CLIP (T v, T amin, T amax)
{ if (v < amin) return amin; else if (v > amax) return amax; else return v; }

/**
* Template method which swaps the values of its two parameters.
*/
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }

/** Is this integer value a power of 2? */
template<typename T> inline bool ISPOWER2(T x) { return x && !(x & (x - 1)); }

Expand Down
6 changes: 3 additions & 3 deletions src/images/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ Decoder::MipMap &Decoder::MipMap::operator=(const MipMap &mipMap) {
}

void Decoder::MipMap::swap(MipMap &right) {
SWAP(width , right.width );
SWAP(height, right.height);
SWAP(size , right.size );
std::swap(width , right.width );
std::swap(height, right.height);
std::swap(size , right.size );

data.swap(right.data);
}
Expand Down
8 changes: 0 additions & 8 deletions tests/common/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ GTEST_TEST(Util, MAXDouble) {
EXPECT_EQ(MAX<double>(-23.0, 23.0), 23.0);
}

GTEST_TEST(Util, SWAP) {
int a = -5, b = 5;
SWAP(a, b);

EXPECT_EQ(a, 5);
EXPECT_EQ(b, -5);
}

GTEST_TEST(Util, ISPOWER2) {
EXPECT_TRUE(ISPOWER2( 2));
EXPECT_TRUE(ISPOWER2( 4));
Expand Down

0 comments on commit 96fac63

Please sign in to comment.