From f8b3c08fd7a5aabe7471c4dfb635d134ee4d8ef3 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Sun, 20 Dec 2015 17:30:34 +0100 Subject: [PATCH] Remove iter_swap specializations. It's a myth that iter_swap helps the compiler produce better code. Let's just use specialized swap instead. --- ginac/ex.h | 14 -------------- ginac/expair.h | 4 ---- ginac/utils.h | 5 +++-- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/ginac/ex.h b/ginac/ex.h index 6fd45c9d..db78536b 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -970,20 +970,6 @@ inline void swap(GiNaC::ex &a, GiNaC::ex &b) a.swap(b); } -/** Specialization of std::iter_swap() for vector iterators. */ -template <> -inline void iter_swap(vector::iterator i1, vector::iterator i2) -{ - i1->swap(*i2); -} - -/** Specialization of std::iter_swap() for list iterators. */ -template <> -inline void iter_swap(list::iterator i1, list::iterator i2) -{ - i1->swap(*i2); -} - } // namespace std #endif // ndef GINAC_EX_H diff --git a/ginac/expair.h b/ginac/expair.h index 3be5a03e..ea26b53d 100644 --- a/ginac/expair.h +++ b/ginac/expair.h @@ -111,10 +111,6 @@ struct expair_swap : public std::binary_function { inline void swap(expair & e1, expair & e2) { e1.swap(e2); } -// This makes STL algorithms use the more efficient swap operation for ex objects -inline void iter_swap(std::vector::iterator i1, std::vector::iterator i2) -{ i1->swap(*i2); } - } // namespace GiNaC #endif // ndef GINAC_EXPAIR_H diff --git a/ginac/utils.h b/ginac/utils.h index 042f14cb..692c7314 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -108,6 +108,7 @@ inline unsigned golden_ratio_hash(p_int n) template int permutation_sign(It first, It last) { + using std::swap; if (first == last) return 0; --last; @@ -122,7 +123,7 @@ int permutation_sign(It first, It last) bool swapped = false; while (i != first) { if (*i < *other) { - std::iter_swap(other, i); + swap(*other, *i); flag = other; swapped = true; sign = -sign; @@ -143,7 +144,7 @@ int permutation_sign(It first, It last) swapped = false; while (i != last) { if (*other < *i) { - std::iter_swap(i, other); + swap(*i, *other); flag = other; swapped = true; sign = -sign; -- 2.47.0