On Fri, 30 Jul 2021 09:32:22 GMT, Thomas Stuefe <stu...@openjdk.org> wrote:
>> [Not a review, just a drive-by comment.] This is a normal and idiomatic >> overload on the const-ness of `this`. > > To expand on Kim's answer. This is a way to solve const/nonconst problems > like https://github.com/openjdk/jdk/pull/4938/files#r679639391. > > You get a const version (suitably returning a write-protected pointer) which > the compiler chooses in const code, and a non-const version for non-const > code, and no awkward const-casts are needed from the outside. > > In this case the implementation is simple enough that I just duplicated it; > were it more complex, I'd call one in terms of the other. We do this in other > places too, see e.g. `ResourceHashTable::lookup_node`. This is ok. This was just new to me. ------------- PR: https://git.openjdk.java.net/jdk/pull/4874