RFR: 8301136: Improve unlink() and unlink_all() of ResourceHashtableBase [v2]
Ioi Lam
iklam at openjdk.org
Thu Jan 26 20:54:17 UTC 2023
On Thu, 26 Jan 2023 20:27:28 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> src/hotspot/share/utilities/resourceHash.hpp line 282:
>>
>>> 280:
>>> 281: while (_number_of_entries > 0 && bucket < bucket_at(sz)) {
>>> 282: Node* node = *bucket;
>>
>> Instead of having two loops for unlinking, I would suggest using the same pattern as iterate/iterate_all so you can share the same loop for the different APIs. This will also allow you to use C++ Lambda for unlinking.
>
> hi, Lam
> Are you suggesting to use lambda+iterate() to implement unlink_all()? If we use `bucket` and `node` captured by the lambda, I think it's possible. However, I think the resultant code is much less readable. Is it worth it?
>
> thanks,
> --lx
I mean we should implement a basic version of unlink() like this
template<typename Function>
void unlink(Function function) const { ... }
Then `unlink_all` and `template<class ITER> void unlink(ITER* iter)` can call into the above template.
-------------
PR: https://git.openjdk.org/jdk/pull/12213
More information about the hotspot-dev
mailing list