[PATCH] Remove redundant accessors in hash tables

Jonathan Wakely jwakely@redhat.com
Thu May 16 10:05:00 GMT 2019


On 16/05/19 07:47 +0200, François Dumont wrote:
>On 5/15/19 5:37 PM, Jonathan Wakely wrote:
>>François,
>>I noticed that _Hash_code_base and _Hashtable_base have a number of
>>member functions which are overloaded for const and non-const:
>>
>>   const _Equal&
>>   _M_eq() const { return _EqualEBO::_S_cget(*this); }
>>
>>   _Equal&
>>   _M_eq() { return _EqualEBO::_S_get(*this); }
>>
>>The non-const ones seem to be unnecessary. They're used in the _M_swap
>>member functions, but all other uses could (and probably should) call
>>the const overload to get a const reference to the function object.
>>
>>If we make the _M_swap members use the EBO accessors directly then we
>>can get rid of the non-const accessors. That makes overload resolution
>>simpler for the compiler (as there's only one function to choose from)
>>and should result in slightly smaller code when inlining is not
>>enabled.
>>
>>Do you see any problem with this patch?
>>
>>
>I think it is more a Pavlov behavior, always providing const and 
>non-const no matter what.
>
>No problem to simplify this.

OK, tested powerpc64le-linux, committed to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4243 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190516/af7a2bd9/attachment.bin>


More information about the Gcc-patches mailing list