Commit f3de79d4 by François Dumont

array: Clean useless white chars.

2014-05-24  François Dumont  <fdumont@gcc.gnu.org>

	* include/profile/array: Clean useless white chars.
	* include/profile/base.h: Likewise.
	* include/profile/iterator_tracker.h: Likewise.
	* include/profile/bitset: Code cleanup and remove not instrumented code.
	* include/profile/deque: Likewise.
	* include/profile/forward_list: Likewise.
	* include/profile/list (std::__profile::_List_profile<>): New.
	(std::__profile::list<>): Inherit from latter and adapt.
	* include/profile/impl/profiler_map_to_unordered_map.h: Generalize
	advise to match any ordered to unordered container conversion.
	* include/profile/ordered_base.h (std::__profile::_Ordered_profile<>):
	New.
	* include/Makefile.am: Add latter.
	* include/Makefile.in: Regenerate.
	* include/profile/map.h (std::__profile::map<>): Inherit from latter,
	remove not instrumented code.
	* include/profile/multimap.h (std::__profile::multimap<>): Likewise.
	* include/profile/set.h (std::__profile::set<>): Likewise.
	* include/profile/multiset.h (std::__profile::multiset<>): Likewise.
	* include/profile/unordered_base.h: Add some line feed.
	* include/profile/unordered_map: Clean useless white chars and replace
	spaces with tabs.
	* include/profile/unordered_set: Likewise.
	* include/profile/vector (std::__profile::_Vector_profile_pre<>): New.
	(std::__profile::_Vector_profile_post<>): New.
	(std::__profile::vector<>): Inherit from latter and adapt.

From-SVN: r210900
parent 1ebfdcab
2014-05-24 François Dumont <fdumont@gcc.gnu.org>
* include/profile/array: Clean useless white chars.
* include/profile/base.h: Likewise.
* include/profile/iterator_tracker.h: Likewise.
* include/profile/bitset: Code cleanup and remove not instrumented code.
* include/profile/deque: Likewise.
* include/profile/forward_list: Likewise.
* include/profile/list (std::__profile::_List_profile<>): New.
(std::__profile::list<>): Inherit from latter and adapt.
* include/profile/impl/profiler_map_to_unordered_map.h: Generalize
advise to match any ordered to unordered container conversion.
* include/profile/ordered_base.h (std::__profile::_Ordered_profile<>):
New.
* include/Makefile.am: Add latter.
* include/Makefile.in: Regenerate.
* include/profile/map.h (std::__profile::map<>): Inherit from latter,
remove not instrumented code.
* include/profile/multimap.h (std::__profile::multimap<>): Likewise.
* include/profile/set.h (std::__profile::set<>): Likewise.
* include/profile/multiset.h (std::__profile::multiset<>): Likewise.
* include/profile/unordered_base.h: Add some line feed.
* include/profile/unordered_map: Clean useless white chars and replace
spaces with tabs.
* include/profile/unordered_set: Likewise.
* include/profile/vector (std::__profile::_Vector_profile_pre<>): New.
(std::__profile::_Vector_profile_post<>): New.
(std::__profile::vector<>): Inherit from latter and adapt.
2014-05-23 Jonathan Wakely <jwakely@redhat.com> 2014-05-23 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/60793 PR libstdc++/60793
......
...@@ -816,6 +816,7 @@ profile_headers = \ ...@@ -816,6 +816,7 @@ profile_headers = \
${profile_srcdir}/map.h \ ${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \ ${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \ ${profile_srcdir}/multiset.h \
${profile_srcdir}/ordered_base.h \
${profile_srcdir}/set \ ${profile_srcdir}/set \
${profile_srcdir}/set.h \ ${profile_srcdir}/set.h \
${profile_srcdir}/iterator_tracker.h ${profile_srcdir}/iterator_tracker.h
......
...@@ -1079,6 +1079,7 @@ profile_headers = \ ...@@ -1079,6 +1079,7 @@ profile_headers = \
${profile_srcdir}/map.h \ ${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \ ${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \ ${profile_srcdir}/multiset.h \
${profile_srcdir}/ordered_base.h \
${profile_srcdir}/set \ ${profile_srcdir}/set \
${profile_srcdir}/set.h \ ${profile_srcdir}/set.h \
${profile_srcdir}/iterator_tracker.h ${profile_srcdir}/iterator_tracker.h
......
...@@ -35,7 +35,8 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -35,7 +35,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __profile namespace __profile
{ {
/// Class std::bitset wrapper with performance instrumentation. /// Class std::bitset wrapper with performance instrumentation, none at the
/// moment.
template<size_t _Nb> template<size_t _Nb>
class bitset class bitset
: public _GLIBCXX_STD_C::bitset<_Nb> : public _GLIBCXX_STD_C::bitset<_Nb>
...@@ -43,60 +44,13 @@ namespace __profile ...@@ -43,60 +44,13 @@ namespace __profile
typedef _GLIBCXX_STD_C::bitset<_Nb> _Base; typedef _GLIBCXX_STD_C::bitset<_Nb> _Base;
public: public:
// bit reference:
class reference
: private _Base::reference
{
typedef typename _Base::reference _Base_ref;
friend class bitset;
reference();
reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT
: _Base_ref(__base)
{ }
public:
reference(const reference& __x) _GLIBCXX_NOEXCEPT
: _Base_ref(__x)
{ }
reference&
operator=(bool __x) _GLIBCXX_NOEXCEPT
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
reference&
operator=(const reference& __x) _GLIBCXX_NOEXCEPT
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
bool
operator~() const _GLIBCXX_NOEXCEPT
{
return ~(*static_cast<const _Base_ref*>(this));
}
operator bool() const _GLIBCXX_NOEXCEPT
{
return *static_cast<const _Base_ref*>(this);
}
reference&
flip() _GLIBCXX_NOEXCEPT
{
_Base_ref::flip();
return *this;
}
};
// 23.3.5.1 constructors: // 23.3.5.1 constructors:
_GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT #if __cplusplus < 201103L
bitset()
: _Base() { } : _Base() { }
#else
constexpr bitset() = default;
#endif
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
constexpr bitset(unsigned long long __val) noexcept constexpr bitset(unsigned long long __val) noexcept
...@@ -221,92 +175,6 @@ namespace __profile ...@@ -221,92 +175,6 @@ namespace __profile
return *this; return *this;
} }
// element access:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
reference
operator[](size_t __pos)
{
return reference(_M_base()[__pos], this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
_GLIBCXX_CONSTEXPR bool
operator[](size_t __pos) const
{
return _Base::operator[](__pos);
}
using _Base::to_ulong;
#if __cplusplus >= 201103L
using _Base::to_ullong;
#endif
template <typename _CharT, typename _Traits, typename _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string() const
{ return _M_base().template to_string<_CharT, _Traits, _Alloc>(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
return _M_base().template
to_string<_CharT, _Traits, _Alloc>(__zero, __one);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 434. bitset::to_string() hard to use.
template<typename _CharT, typename _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string() const
{ return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 853. to_string needs updating with zero and one.
template<class _CharT, class _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{ return to_string<_CharT, _Traits,
std::allocator<_CharT> >(__zero, __one); }
template<typename _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string() const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >();
}
template<class _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >(__zero, __one);
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string() const
{
return to_string<char,std::char_traits<char>,std::allocator<char> >();
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string(char __zero, char __one = '1') const
{
return to_string<char, std::char_traits<char>,
std::allocator<char> >(__zero, __one);
}
using _Base::count;
using _Base::size;
bool bool
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() == __rhs; } { return _M_base() == __rhs; }
...@@ -315,11 +183,6 @@ namespace __profile ...@@ -315,11 +183,6 @@ namespace __profile
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
{ return _M_base() != __rhs; } { return _M_base() != __rhs; }
using _Base::test;
using _Base::all;
using _Base::any;
using _Base::none;
bitset<_Nb> bitset<_Nb>
operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT
{ return bitset<_Nb>(_M_base() << __pos); } { return bitset<_Nb>(_M_base() << __pos); }
......
...@@ -43,26 +43,29 @@ namespace __profile ...@@ -43,26 +43,29 @@ namespace __profile
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base; typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
public: public:
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef typename _Base::reverse_iterator reverse_iterator;
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
typedef typename _Base::size_type size_type; typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type; typedef typename _Base::value_type value_type;
typedef _Tp value_type;
typedef _Allocator allocator_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
// 23.2.1.1 construct/copy/destroy: // 23.2.1.1 construct/copy/destroy:
#if __cplusplus < 201103L
deque() deque()
: _Base() { } : _Base() { }
deque(const deque& __x)
: _Base(__x) { }
~deque() { }
#else
deque() = default;
deque(const deque&) = default;
deque(deque&&) = default;
~deque() = default;
deque(initializer_list<value_type> __l,
const _Allocator& __a = _Allocator())
: _Base(__l, __a) { }
#endif
explicit explicit
deque(const _Allocator& __a) deque(const _Allocator& __a)
...@@ -94,335 +97,37 @@ namespace __profile ...@@ -94,335 +97,37 @@ namespace __profile
: _Base(__first, __last, __a) : _Base(__first, __last, __a)
{ } { }
deque(const deque& __x)
: _Base(__x) { }
deque(const _Base& __x) deque(const _Base& __x)
: _Base(__x) { } : _Base(__x) { }
#if __cplusplus >= 201103L #if __cplusplus < 201103L
deque(deque&& __x)
: _Base(std::move(__x))
{ }
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
#endif
~deque() _GLIBCXX_NOEXCEPT { }
deque& deque&
operator=(const deque& __x) operator=(const deque& __x)
{ {
*static_cast<_Base*>(this) = __x; _M_base() = __x;
return *this; return *this;
} }
#else
deque&
operator=(const deque&) = default;
#if __cplusplus >= 201103L
deque& deque&
operator=(deque&& __x) noexcept operator=(deque&&) = default;
{
// NB: DR 1204.
// NB: DR 675.
this->clear();
this->swap(__x);
return *this;
}
deque& deque&
operator=(initializer_list<value_type> __l) operator=(initializer_list<value_type> __l)
{ {
*static_cast<_Base*>(this) = __l; _M_base() = __l;
return *this; return *this;
} }
#endif #endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
void
assign(_InputIterator __first, _InputIterator __last)
{
_Base::assign(__first, __last);
}
void
assign(size_type __n, const _Tp& __t)
{
_Base::assign(__n, __t);
}
#if __cplusplus >= 201103L
void
assign(initializer_list<value_type> __l)
{
_Base::assign(__l);
}
#endif
using _Base::get_allocator;
// iterators:
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin()); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin()); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end()); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end()); }
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin()); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end()); }
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
// 23.2.1.2 capacity:
using _Base::size;
using _Base::max_size;
#if __cplusplus >= 201103L
void
resize(size_type __sz)
{
_Base::resize(__sz);
}
void void
resize(size_type __sz, const _Tp& __c) swap(deque& __x)
{
_Base::resize(__sz, __c);
}
#else
void
resize(size_type __sz, _Tp __c = _Tp())
{
_Base::resize(__sz, __c);
}
#endif
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
using _Base::shrink_to_fit; noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif #endif
{ _Base::swap(__x); }
using _Base::empty;
// element access:
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
return _M_base()[__n];
}
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
return _M_base()[__n];
}
using _Base::at;
reference
front() _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
const_reference
front() const _GLIBCXX_NOEXCEPT
{
return _Base::front();
}
reference
back() _GLIBCXX_NOEXCEPT
{
return _Base::back();
}
const_reference
back() const _GLIBCXX_NOEXCEPT
{
return _Base::back();
}
// 23.2.1.3 modifiers:
void
push_front(const _Tp& __x)
{
_Base::push_front(__x);
}
void
push_back(const _Tp& __x)
{
_Base::push_back(__x);
}
#if __cplusplus >= 201103L
void
push_front(_Tp&& __x)
{ emplace_front(std::move(__x)); }
void
push_back(_Tp&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
void
emplace_front(_Args&&... __args)
{
_Base::emplace_front(std::forward<_Args>(__args)...);
}
template<typename... _Args>
void
emplace_back(_Args&&... __args)
{
_Base::emplace_back(std::forward<_Args>(__args)...);
}
template<typename... _Args>
iterator
emplace(const_iterator __position, _Args&&... __args)
{
typename _Base::iterator __res = _Base::emplace(__position,
std::forward<_Args>(__args)...);
return iterator(__res);
}
#endif
iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const _Tp& __x)
#else
insert(iterator __position, const _Tp& __x)
#endif
{
typename _Base::iterator __res = _Base::insert(__position, __x);
return iterator(__res);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, _Tp&& __x)
{ return emplace(__position, std::move(__x)); }
iterator
insert(const_iterator __p, initializer_list<value_type> __l)
{ return _Base::insert(__p, __l); }
#endif
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, size_type __n, const _Tp& __x)
{ return _Base::insert(__position, __n, __x); }
#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
{ _Base::insert(__position, __n, __x); }
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position,
_InputIterator __first, _InputIterator __last)
{ return _Base::insert(__position, __first, __last); }
#else
template<typename _InputIterator>
void
insert(iterator __position,
_InputIterator __first, _InputIterator __last)
{ _Base::insert(__position, __first, __last); }
#endif
void
pop_front() _GLIBCXX_NOEXCEPT
{
_Base::pop_front();
}
void
pop_back() _GLIBCXX_NOEXCEPT
{
_Base::pop_back();
}
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
erase(iterator __position)
#endif
{
return _Base::erase(__position);
}
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
return _Base::erase(__first, __last);
}
void
swap(deque& __x) _GLIBCXX_NOEXCEPT
{
_Base::swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
_Base::clear();
}
_Base& _Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; } _M_base() _GLIBCXX_NOEXCEPT { return *this; }
......
...@@ -46,13 +46,9 @@ namespace __profile ...@@ -46,13 +46,9 @@ namespace __profile
{ {
typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base; typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base;
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_GLIBCXX_STD_C::_Fwd_list_node<_Tp>>::other _Node_alloc_type;
typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits;
public: public:
typedef typename _Base::size_type size_type; typedef typename _Base::size_type size_type;
typedef typename _Base::const_iterator const_iterator;
// 23.2.3.1 construct/copy/destroy: // 23.2.3.1 construct/copy/destroy:
explicit explicit
...@@ -84,43 +80,80 @@ namespace __profile ...@@ -84,43 +80,80 @@ namespace __profile
: _Base(__first, __last, __al) : _Base(__first, __last, __al)
{ } { }
forward_list(const forward_list& __list) forward_list(const forward_list&) = default;
: _Base(__list) forward_list(forward_list&&) = default;
{ }
forward_list(forward_list&& __list) noexcept
: _Base(std::move(__list)) { }
forward_list(std::initializer_list<_Tp> __il, forward_list(std::initializer_list<_Tp> __il,
const _Alloc& __al = _Alloc()) const _Alloc& __al = _Alloc())
: _Base(__il, __al) : _Base(__il, __al)
{ } { }
~forward_list() noexcept ~forward_list() = default;
{ }
forward_list& forward_list&
operator=(const forward_list& __list) operator=(const forward_list&) = default;
{
static_cast<_Base&>(*this) = __list;
return *this;
}
forward_list& forward_list&
operator=(forward_list&& __list) operator=(forward_list&&) = default;
noexcept(_Node_alloc_traits::_S_nothrow_move())
{
static_cast<_Base&>(*this) = std::move(__list);
return *this;
}
forward_list& forward_list&
operator=(std::initializer_list<_Tp> __il) operator=(std::initializer_list<_Tp> __il)
{ {
static_cast<_Base&>(*this) = __il; _M_base() = __il;
return *this; return *this;
} }
void
swap(forward_list& __fl)
noexcept( noexcept(declval<_Base>().swap(__fl)) )
{ _Base::swap(__fl); }
void
splice_after(const_iterator __pos, forward_list&& __fl)
{ _Base::splice_after(__pos, std::move(__fl)); }
void
splice_after(const_iterator __pos, forward_list& __list)
{ _Base::splice_after(__pos, __list); }
void
splice_after(const_iterator __pos, forward_list&& __list,
const_iterator __i)
{ _Base::splice_after(__pos, std::move(__list), __i); }
void
splice_after(const_iterator __pos, forward_list& __list,
const_iterator __i)
{ _Base::splice_after(__pos, __list, __i); }
void
splice_after(const_iterator __pos, forward_list&& __list,
const_iterator __before, const_iterator __last)
{ _Base::splice_after(__pos, std::move(__list), __before, __last); }
void
splice_after(const_iterator __pos, forward_list& __list,
const_iterator __before, const_iterator __last)
{ _Base::splice_after(__pos, __list, __before, __last); }
void
merge(forward_list&& __list)
{ _Base::merge(std::move(__list)); }
void
merge(forward_list& __list)
{ _Base::merge(__list); }
template<typename _Comp>
void
merge(forward_list&& __list, _Comp __comp)
{ _Base::merge(std::move(__list), __comp); }
template<typename _Comp>
void
merge(forward_list& __list, _Comp __comp)
{ _Base::merge(__list, __comp); }
_Base& _Base&
_M_base() noexcept { return *this; } _M_base() noexcept { return *this; }
......
...@@ -108,32 +108,38 @@ namespace __gnu_profile ...@@ -108,32 +108,38 @@ namespace __gnu_profile
std::string std::string
__advice() const __advice() const
{ return "change std::map to std::unordered_map"; } { return "prefer an unordered container"; }
void void
__record_insert(std::size_t __size, std::size_t __count) __record_insert(std::size_t __size, std::size_t __count)
{ {
_M_insert += __count; ++_M_insert;
if (__count)
{
_M_map_cost += __count * __map_insert_cost(__size); _M_map_cost += __count * __map_insert_cost(__size);
_M_umap_cost _M_umap_cost
+= (__count += (__count
* _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value); * _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value);
} }
}
void void
__record_erase(std::size_t __size, std::size_t __count) __record_erase(std::size_t __size, std::size_t __count)
{ {
_M_erase += __count; ++_M_erase;
if (__count)
{
_M_map_cost += __count * __map_erase_cost(__size); _M_map_cost += __count * __map_erase_cost(__size);
_M_umap_cost _M_umap_cost
+= (__count += (__count
* _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value); * _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value);
} }
}
void void
__record_find(std::size_t __size) __record_find(std::size_t __size)
{ {
_M_find += 1; ++_M_find;
_M_map_cost += __map_find_cost(__size); _M_map_cost += __map_find_cost(__size);
_M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value; _M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value;
} }
...@@ -182,7 +188,7 @@ namespace __gnu_profile ...@@ -182,7 +188,7 @@ namespace __gnu_profile
public: public:
__trace_map2umap() __trace_map2umap()
: __trace_base<__map2umap_info, __map2umap_stack_info>() : __trace_base<__map2umap_info, __map2umap_stack_info>()
{ __id = "map-to-unordered-map"; } { __id = "ordered-to-unordered"; }
}; };
inline void inline void
......
...@@ -35,7 +35,6 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -35,7 +35,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
namespace __profile namespace __profile
{ {
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
class __iterator_tracker class __iterator_tracker
{ {
......
// Profiling unordered containers implementation details -*- C++ -*-
// Copyright (C) 2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/ordered_base.h
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_ORDERED
#define _GLIBCXX_PROFILE_ORDERED 1
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
{
template<typename _Cont>
class _Ordered_profile
{
_Cont&
_M_conjure()
{ return *static_cast<_Cont*>(this); }
public:
_Ordered_profile() _GLIBCXX_NOEXCEPT
{ __profcxx_map_to_unordered_map_construct(&_M_conjure()); }
#if __cplusplus >= 201103L
_Ordered_profile(const _Ordered_profile&) noexcept
: _Ordered_profile() { }
_Ordered_profile(_Ordered_profile&&) noexcept
: _Ordered_profile() { }
_Ordered_profile&
operator=(const _Ordered_profile&) = default;
_Ordered_profile&
operator=(_Ordered_profile&&) = default;
#endif
~_Ordered_profile()
{ __profcxx_map_to_unordered_map_destruct(&_M_conjure()); }
};
} // namespace __profile
} // namespace std
#endif
...@@ -210,6 +210,7 @@ namespace __profile ...@@ -210,6 +210,7 @@ namespace __profile
auto __lend = __uc.end(__bkt); auto __lend = __uc.end(__bkt);
for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit) for (++__it, ++__lit; __lit != __lend; ++__it, ++__lit)
++__chain; ++__chain;
if (__chain) if (__chain)
{ {
++__chain; ++__chain;
...@@ -245,6 +246,7 @@ namespace __profile ...@@ -245,6 +246,7 @@ namespace __profile
__pit = __it; __pit = __it;
} }
} }
if (__chain) if (__chain)
{ {
++__chain; ++__chain;
......
...@@ -81,8 +81,7 @@ namespace __profile ...@@ -81,8 +81,7 @@ namespace __profile
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) : _Base(__n, __hf, __eql, __a) { }
{ }
template<typename _InputIterator> template<typename _InputIterator>
unordered_map(_InputIterator __f, _InputIterator __l, unordered_map(_InputIterator __f, _InputIterator __l,
...@@ -90,39 +89,33 @@ namespace __profile ...@@ -90,39 +89,33 @@ namespace __profile
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a) : _Base(__f, __l, __n, __hf, __eql, __a) { }
{ }
unordered_map(const unordered_map&) = default; unordered_map(const unordered_map&) = default;
unordered_map(const _Base& __x) unordered_map(const _Base& __x)
: _Base(__x) : _Base(__x) { }
{ }
unordered_map(unordered_map&&) = default; unordered_map(unordered_map&&) = default;
explicit explicit
unordered_map(const allocator_type& __a) unordered_map(const allocator_type& __a)
: _Base(__a) : _Base(__a) { }
{ }
unordered_map(const unordered_map& __umap, unordered_map(const unordered_map& __umap,
const allocator_type& __a) const allocator_type& __a)
: _Base(__umap, __a) : _Base(__umap, __a) { }
{ }
unordered_map(unordered_map&& __umap, unordered_map(unordered_map&& __umap,
const allocator_type& __a) const allocator_type& __a)
: _Base(std::move(__umap._M_base()), __a) : _Base(std::move(__umap._M_base()), __a) { }
{ }
unordered_map(initializer_list<value_type> __l, unordered_map(initializer_list<value_type> __l,
size_type __n = 0, size_type __n = 0,
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a) : _Base(__l, __n, __hf, __eql, __a) { }
{ }
unordered_map& unordered_map&
operator=(const unordered_map&) = default; operator=(const unordered_map&) = default;
...@@ -333,8 +326,7 @@ namespace __profile ...@@ -333,8 +326,7 @@ namespace __profile
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__n, __hf, __eql, __a) : _Base(__n, __hf, __eql, __a) { }
{ }
template<typename _InputIterator> template<typename _InputIterator>
unordered_multimap(_InputIterator __f, _InputIterator __l, unordered_multimap(_InputIterator __f, _InputIterator __l,
...@@ -342,39 +334,33 @@ namespace __profile ...@@ -342,39 +334,33 @@ namespace __profile
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__f, __l, __n, __hf, __eql, __a) : _Base(__f, __l, __n, __hf, __eql, __a) { }
{ }
unordered_multimap(const unordered_multimap&) = default; unordered_multimap(const unordered_multimap&) = default;
unordered_multimap(const _Base& __x) unordered_multimap(const _Base& __x)
: _Base(__x) : _Base(__x) { }
{ }
unordered_multimap(unordered_multimap&&) = default; unordered_multimap(unordered_multimap&&) = default;
explicit explicit
unordered_multimap(const allocator_type& __a) unordered_multimap(const allocator_type& __a)
: _Base(__a) : _Base(__a) { }
{ }
unordered_multimap(const unordered_multimap& __ummap, unordered_multimap(const unordered_multimap& __ummap,
const allocator_type& __a) const allocator_type& __a)
: _Base(__ummap._M_base(), __a) : _Base(__ummap._M_base(), __a) { }
{ }
unordered_multimap(unordered_multimap&& __ummap, unordered_multimap(unordered_multimap&& __ummap,
const allocator_type& __a) const allocator_type& __a)
: _Base(std::move(__ummap._M_base()), __a) : _Base(std::move(__ummap._M_base()), __a) { }
{ }
unordered_multimap(initializer_list<value_type> __l, unordered_multimap(initializer_list<value_type> __l,
size_type __n = 0, size_type __n = 0,
const hasher& __hf = hasher(), const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(), const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__l, __n, __hf, __eql, __a) : _Base(__l, __n, __hf, __eql, __a) { }
{ }
unordered_multimap& unordered_multimap&
operator=(const unordered_multimap&) = default; operator=(const unordered_multimap&) = default;
......
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