RFR: 8301136: Improve unlink() and unlink_all() of ResourceHashtableBase [v2]

Xin Liu xliu at openjdk.org
Thu Jan 26 20:30:22 UTC 2023


On Thu, 26 Jan 2023 17:22:24 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Quit early if cnt is zero.
>
> 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

-------------

PR: https://git.openjdk.org/jdk/pull/12213


More information about the hotspot-dev mailing list