RFR: 8314502: Change the comparator taking version of GrowableArray::find to be a template method [v3]
Quan Anh Mai
qamai at openjdk.org
Tue Aug 29 03:01:11 UTC 2023
On Mon, 28 Aug 2023 11:03:51 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
>> The `find` method now is
>> ```C++
>> template<typename T>
>> int find(T* token, bool f(T*, E)) const {
>> ...
>>
>> Any other functions which use this are also changed.
>> Local linux-x64-debug hotspot:tier1 passed. Mach5 tier1 build on linux and Windows passed.
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>
> find_from_end and its caller are also updated.
This is similar to `std::find_if` and should be just:
template<class UnaryPredicate>
int find(UnaryPredicate p) const {
for (int i = 0; i < _len; i++) {
if (p(_data[i])) {
return i;
}
}
return -1;
}
Regarding the current approach, the comparator should take a `const E&` instead of an `E`, and the token passed in should be `const` also.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15418#issuecomment-1696695109
More information about the hotspot-dev
mailing list