[PATCH] Remove redundant accessors in hash tables
Jonathan Wakely
jwakely@redhat.com
Thu May 16 13:24:00 GMT 2019
On 16/05/19 13:30 +0100, Jonathan Wakely wrote:
>On 16/05/19 11:05 +0100, Jonathan Wakely wrote:
>>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.
>
>I don't see a need for the _Hashtable_ebo_helper member functions to
>be static. They return a member of *this, but are static so *this has
>to be passed as a parameter. We could just make them non-static.
>
>It seems to have always been that way since the first version of the
>patch that added the helpers:
>https://gcc.gnu.org/ml/libstdc++/2011-12/msg00139.html
>
>This patch passes all tests. I plan to commit this to trunk too.
And another one (which I've actually had sitting in a local branch for
a few years!)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3541 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190516/61016220/attachment.bin>
More information about the Libstdc++
mailing list