]> www.ginac.de Git - ginac.git/commitdiff
Remove iter_swap specializations.
authorRichard Kreckel <kreckel@ginac.de>
Sun, 20 Dec 2015 16:30:34 +0000 (17:30 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Sun, 20 Dec 2015 16:30:34 +0000 (17:30 +0100)
It's a myth that iter_swap helps the compiler produce better code.
Let's just use specialized swap instead.

ginac/ex.h
ginac/expair.h
ginac/utils.h

index 6fd45c9d24356bc2af5a2b6458adb719a383c25c..db78536b45bae79c4b451214290f7e8e56d21f90 100644 (file)
@@ -970,20 +970,6 @@ inline void swap(GiNaC::ex &a, GiNaC::ex &b)
        a.swap(b);
 }
 
-/** Specialization of std::iter_swap() for vector<ex> iterators. */
-template <>
-inline void iter_swap(vector<GiNaC::ex>::iterator i1, vector<GiNaC::ex>::iterator i2)
-{
-       i1->swap(*i2);
-}
-
-/** Specialization of std::iter_swap() for list<ex> iterators. */
-template <>
-inline void iter_swap(list<GiNaC::ex>::iterator i1, list<GiNaC::ex>::iterator i2)
-{
-       i1->swap(*i2);
-}
-
 } // namespace std
 
 #endif // ndef GINAC_EX_H
index 3be5a03e20b55ea2ba34d7409d5e0b9023c493d1..ea26b53d3420f87a96b5075c2d5c43cac823eac8 100644 (file)
@@ -111,10 +111,6 @@ struct expair_swap : public std::binary_function<expair, expair, void> {
 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<expair>::iterator i1, std::vector<expair>::iterator i2)
-{ i1->swap(*i2); }
-
 } // namespace GiNaC
 
 #endif // ndef GINAC_EXPAIR_H
index 042f14cb93c8185e6f2c4a1ab1989d74b18eae26..692c731453fa371f699767f0fa7f7d972d3889bd 100644 (file)
@@ -108,6 +108,7 @@ inline unsigned golden_ratio_hash(p_int n)
 template <class It>
 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;