summaryrefslogtreecommitdiffstats
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-08-01 17:29:28 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-08-01 17:29:28 +0000
commit0f242bea1097ab7a49dccf851c36f76194977ddb (patch)
treeb032bada83dfcc989317036b501bf5544cf94ade /libcxx/include/algorithm
parent62f0ffd733102a260e326cfb191f733a1b4569d1 (diff)
downloadbcm5719-llvm-0f242bea1097ab7a49dccf851c36f76194977ddb.tar.gz
bcm5719-llvm-0f242bea1097ab7a49dccf851c36f76194977ddb.zip
Taking another swing at correctly optimizing fill_n.
llvm-svn: 187587
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm20
1 files changed, 11 insertions, 9 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 119fbbbbac4..1403fd68fe7 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1987,17 +1987,23 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _
template <class _OutputIterator, class _Size, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
-__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, false_type)
+__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
for (; __n > 0; ++__first, --__n)
*__first = __value_;
return __first;
}
-template <class _OutputIterator, class _Size, class _Tp>
+template <class _Tp, class _Size, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_, true_type)
+typename enable_if
+<
+ is_integral<_Tp>::value && sizeof(_Tp) == 1 &&
+ !is_same<_Tp, bool>::value &&
+ is_integral<_Up>::value && sizeof(_Up) == 1,
+ _Tp*
+>::type
+__fill_n(_Tp* __first, _Size __n,_Up __value_)
{
if (__n > 0)
_VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n));
@@ -2009,11 +2015,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
- return _VSTD::__fill_n(__first, __n, __value_, integral_constant<bool,
- is_pointer<_OutputIterator>::value &&
- is_trivially_assignable<typename remove_pointer<_OutputIterator>::type, _Tp>::value &&
- is_convertible<_Tp, unsigned char>::value &&
- sizeof(typename remove_pointer<_OutputIterator>::type) == 1>());
+ return _VSTD::__fill_n(__first, __n, __value_);
}
// fill
OpenPOWER on IntegriCloud