Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping an element with itself

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@341975 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2018-09-11 18:33:45 +00:00
parent 5a86ba0aa0
commit 53c8e25037

View File

@@ -2987,7 +2987,8 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
for (--__last; __first < __last; ++__first, --__d)
{
difference_type __i = __rand(__d);
swap(*__first, *(__first + __i));
if (__i != difference_type(0))
swap(*__first, *(__first + __i));
}
}
}