Commit 0bc229db by Jonathan Wakely Committed by Jonathan Wakely

Remove unnecessary non-const accessors in hash table bases

The const accessors are OK (and arguably more correct) for most callers
to use. The _M_swap functions that use the non-const overloads can just
directly use the _S_get members of the EBO helpers.

	* include/bits/hashtable_policy.h (_Hash_code_base::_M_swap): Use
	_S_get accessors for members in EBO helpers.
	(_Hash_code_base::_M_extract(), _Hash_code_base::_M_ranged_hash())
	(_Hash_code_base::_M_h1(), _Hash_code_base::_M_h2()): Remove non-const
	overloads.
	(_Hashtable_base::_M_swap): Use _S_get accessors for members in EBO
	helpers.
	(_Hashtable_base::_M_eq()): Remove non-const overload.

From-SVN: r271286
parent 4b8e35f1
2019-05-16 Jonathan Wakely <jwakely@redhat.com>
* include/bits/hashtable_policy.h (_Hash_code_base::_M_swap): Use
_S_get accessors for members in EBO helpers.
(_Hash_code_base::_M_extract(), _Hash_code_base::_M_ranged_hash())
(_Hash_code_base::_M_h1(), _Hash_code_base::_M_h2()): Remove non-const
overloads.
(_Hashtable_base::_M_swap): Use _S_get accessors for members in EBO
helpers.
(_Hashtable_base::_M_eq()): Remove non-const overload.
2019-05-15 Jonathan Wakely <jwakely@redhat.com> 2019-05-15 Jonathan Wakely <jwakely@redhat.com>
* include/std/variant (visit, visit<R>): Qualify calls to __do_visit. * include/std/variant (visit, visit<R>): Qualify calls to __do_visit.
......
...@@ -1229,21 +1229,16 @@ namespace __detail ...@@ -1229,21 +1229,16 @@ namespace __detail
void void
_M_swap(_Hash_code_base& __x) _M_swap(_Hash_code_base& __x)
{ {
std::swap(_M_extract(), __x._M_extract()); std::swap(__ebo_extract_key::_S_get(*this),
std::swap(_M_ranged_hash(), __x._M_ranged_hash()); __ebo_extract_key::_S_get(__x));
std::swap(__ebo_hash::_S_get(*this), __ebo_hash::_S_get(__x));
} }
const _ExtractKey& const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); } _M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _Hash& const _Hash&
_M_ranged_hash() const { return __ebo_hash::_S_cget(*this); } _M_ranged_hash() const { return __ebo_hash::_S_cget(*this); }
_Hash&
_M_ranged_hash() { return __ebo_hash::_S_get(*this); }
}; };
// No specialization for ranged hash function while caching hash codes. // No specialization for ranged hash function while caching hash codes.
...@@ -1322,28 +1317,20 @@ namespace __detail ...@@ -1322,28 +1317,20 @@ namespace __detail
void void
_M_swap(_Hash_code_base& __x) _M_swap(_Hash_code_base& __x)
{ {
std::swap(_M_extract(), __x._M_extract()); std::swap(__ebo_extract_key::_S_get(*this),
std::swap(_M_h1(), __x._M_h1()); __ebo_extract_key::_S_get(__x));
std::swap(_M_h2(), __x._M_h2()); std::swap(__ebo_h1::_S_get(*this), __ebo_h1::_S_get(__x));
std::swap(__ebo_h2::_S_get(*this), __ebo_h2::_S_get(__x));
} }
const _ExtractKey& const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); } _M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _H1& const _H1&
_M_h1() const { return __ebo_h1::_S_cget(*this); } _M_h1() const { return __ebo_h1::_S_cget(*this); }
_H1&
_M_h1() { return __ebo_h1::_S_get(*this); }
const _H2& const _H2&
_M_h2() const { return __ebo_h2::_S_cget(*this); } _M_h2() const { return __ebo_h2::_S_cget(*this); }
_H2&
_M_h2() { return __ebo_h2::_S_get(*this); }
}; };
/// Specialization: hash function and range-hashing function, /// Specialization: hash function and range-hashing function,
...@@ -1410,28 +1397,20 @@ namespace __detail ...@@ -1410,28 +1397,20 @@ namespace __detail
void void
_M_swap(_Hash_code_base& __x) _M_swap(_Hash_code_base& __x)
{ {
std::swap(_M_extract(), __x._M_extract()); std::swap(__ebo_extract_key::_S_get(*this),
std::swap(_M_h1(), __x._M_h1()); __ebo_extract_key::_S_get(__x));
std::swap(_M_h2(), __x._M_h2()); std::swap(__ebo_h1::_S_get(*this), __ebo_h1::_S_get(__x));
std::swap(__ebo_h2::_S_get(*this), __ebo_h2::_S_get(__x));
} }
const _ExtractKey& const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); } _M_extract() const { return __ebo_extract_key::_S_cget(*this); }
_ExtractKey&
_M_extract() { return __ebo_extract_key::_S_get(*this); }
const _H1& const _H1&
_M_h1() const { return __ebo_h1::_S_cget(*this); } _M_h1() const { return __ebo_h1::_S_cget(*this); }
_H1&
_M_h1() { return __ebo_h1::_S_get(*this); }
const _H2& const _H2&
_M_h2() const { return __ebo_h2::_S_cget(*this); } _M_h2() const { return __ebo_h2::_S_cget(*this); }
_H2&
_M_h2() { return __ebo_h2::_S_get(*this); }
}; };
/** /**
...@@ -1840,14 +1819,11 @@ namespace __detail ...@@ -1840,14 +1819,11 @@ namespace __detail
_M_swap(_Hashtable_base& __x) _M_swap(_Hashtable_base& __x)
{ {
__hash_code_base::_M_swap(__x); __hash_code_base::_M_swap(__x);
std::swap(_M_eq(), __x._M_eq()); std::swap(_EqualEBO::_S_get(*this), _EqualEBO::_S_get(__x));
} }
const _Equal& const _Equal&
_M_eq() const { return _EqualEBO::_S_cget(*this); } _M_eq() const { return _EqualEBO::_S_cget(*this); }
_Equal&
_M_eq() { return _EqualEBO::_S_get(*this); }
}; };
/** /**
......
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