Commit e762c6f4 by Jan Hubicka Committed by Jan Hubicka

array (at): Do not use builtin_expect.

	* include/tr1_impl/array (at): Do not use builtin_expect.
	* include/ext/throw_allocator.h (allocate): Likewise.
	* include/ext/pool_allocator.h (allocate): Likweise.
	* include/ext/bitmap_allocator.h (allocate): Likewise.
	* include/ext/rc_string_base.h (_S_construct): Likewise.
	* include/ext/malloc_allocator.h (allocate): Likewise.
	* include/ext/mt_allocator.h (allocate): Likewise.
	* include/ext/sso_string_base.h (_M_construct): Likewise.
	* include/bits/basic_string.tcc (_S_construct): Likewise.

From-SVN: r146681
parent aa829fa1
2009-04-22 Jan Hubicka <jh@suse.cz> 2009-04-22 Jan Hubicka <jh@suse.cz>
* include/tr1_impl/array (at): Do not use builtin_expect.
* include/ext/throw_allocator.h (allocate): Likewise.
* include/ext/pool_allocator.h (allocate): Likweise.
* include/ext/bitmap_allocator.h (allocate): Likewise.
* include/ext/rc_string_base.h (_S_construct): Likewise.
* include/ext/malloc_allocator.h (allocate): Likewise.
* include/ext/mt_allocator.h (allocate): Likewise.
* include/ext/sso_string_base.h (_M_construct): Likewise.
* include/bits/basic_string.tcc (_S_construct): Likewise.
2009-04-22 Jan Hubicka <jh@suse.cz>
* include/c_std/cstdlib (abort, exit, _Exit): Mark noreturn throw (). * include/c_std/cstdlib (abort, exit, _Exit): Mark noreturn throw ().
(atexit, atoll, stroll, strtoull): Mark throw () (atexit, atoll, stroll, strtoull): Mark throw ()
* include/c_std/cstdio (snprintf, vsnprintf, vscanf): Mark throw (). * include/c_std/cstdio (snprintf, vsnprintf, vscanf): Mark throw ().
......
...@@ -129,8 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -129,8 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return _S_empty_rep()._M_refdata(); return _S_empty_rep()._M_refdata();
#endif #endif
// NB: Not required, but considered best practice. // NB: Not required, but considered best practice.
if (__builtin_expect(__gnu_cxx::__is_null_pointer(__beg) if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end)
&& __beg != __end, 0))
__throw_logic_error(__N("basic_string::_S_construct NULL not valid")); __throw_logic_error(__N("basic_string::_S_construct NULL not valid"));
const size_type __dnew = static_cast<size_type>(std::distance(__beg, const size_type __dnew = static_cast<size_type>(std::distance(__beg,
......
...@@ -1049,7 +1049,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -1049,7 +1049,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer pointer
allocate(size_type __n) allocate(size_type __n)
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
if (__builtin_expect(__n == 1, true)) if (__builtin_expect(__n == 1, true))
......
...@@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer pointer
allocate(size_type __n, const void* = 0) allocate(size_type __n, const void* = 0)
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
pointer __ret = static_cast<_Tp*>(std::malloc(__n * sizeof(_Tp))); pointer __ret = static_cast<_Tp*>(std::malloc(__n * sizeof(_Tp)));
......
...@@ -674,7 +674,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -674,7 +674,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
__mt_alloc<_Tp, _Poolp>:: __mt_alloc<_Tp, _Poolp>::
allocate(size_type __n, const void*) allocate(size_type __n, const void*)
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
__policy_type::_S_initialize_once(); __policy_type::_S_initialize_once();
......
...@@ -83,7 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -83,7 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer pointer
allocate(size_type __n, const void* = 0) allocate(size_type __n, const void* = 0)
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
......
...@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer __ret = 0; pointer __ret = 0;
if (__builtin_expect(__n != 0, true)) if (__builtin_expect(__n != 0, true))
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
// If there is a race through here, assume answer from getenv // If there is a race through here, assume answer from getenv
...@@ -230,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -230,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*__free_list = __result->_M_free_list_link; *__free_list = __result->_M_free_list_link;
__ret = reinterpret_cast<_Tp*>(__result); __ret = reinterpret_cast<_Tp*>(__result);
} }
if (__builtin_expect(__ret == 0, 0)) if (__ret == 0)
std::__throw_bad_alloc(); std::__throw_bad_alloc();
} }
} }
......
...@@ -546,7 +546,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -546,7 +546,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
return _S_empty_rep._M_refcopy(); return _S_empty_rep._M_refcopy();
// NB: Not required, but considered best practice. // NB: Not required, but considered best practice.
if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0)) if (__is_null_pointer(__beg) && __beg != __end)
std::__throw_logic_error(__N("__rc_string_base::" std::__throw_logic_error(__N("__rc_string_base::"
"_S_construct NULL not valid")); "_S_construct NULL not valid"));
......
...@@ -428,7 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -428,7 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
std::forward_iterator_tag) std::forward_iterator_tag)
{ {
// NB: Not required, but considered best practice. // NB: Not required, but considered best practice.
if (__builtin_expect(__is_null_pointer(__beg) && __beg != __end, 0)) if (__is_null_pointer(__beg) && __beg != __end)
std::__throw_logic_error(__N("__sso_string_base::" std::__throw_logic_error(__N("__sso_string_base::"
"_M_construct NULL not valid")); "_M_construct NULL not valid"));
......
...@@ -220,7 +220,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -220,7 +220,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer pointer
allocate(size_type __n, std::allocator<void>::const_pointer hint = 0) allocate(size_type __n, std::allocator<void>::const_pointer hint = 0)
{ {
if (__builtin_expect(__n > this->max_size(), false)) if (__n > this->max_size())
std::__throw_bad_alloc(); std::__throw_bad_alloc();
throw_conditionally(); throw_conditionally();
......
...@@ -149,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -149,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
reference reference
at(size_type __n) at(size_type __n)
{ {
if (__builtin_expect(__n >= _Nm, false)) if (__n >= _Nm)
std::__throw_out_of_range(__N("array::at")); std::__throw_out_of_range(__N("array::at"));
return _M_instance[__n]; return _M_instance[__n];
} }
...@@ -157,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 ...@@ -157,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
const_reference const_reference
at(size_type __n) const at(size_type __n) const
{ {
if (__builtin_expect(__n >= _Nm, false)) if (__n >= _Nm)
std::__throw_out_of_range(__N("array::at")); std::__throw_out_of_range(__N("array::at"));
return _M_instance[__n]; return _M_instance[__n];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment