RFR: 8257466: Improve enum iteration [v2]

Kim Barrett kbarrett at openjdk.java.net
Wed Dec 2 02:30:15 UTC 2020


On Wed, 2 Dec 2020 02:12:19 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> src/hotspot/share/utilities/enumIterator.hpp line 115:
>> 
>>> 113:     static constexpr EnumeratorRangeImpl::Underlying<T> _start =        \
>>> 114:       EnumeratorRangeImpl::underlying<T>(Start);                        \
>>> 115:     static constexpr EnumeratorRangeImpl::Underlying<T> _end =          \
>> 
>> Why do we need to call `underlying<T>(Start)` here? Can it be simplified as 
>> static constexpr EnumeratorRangeImpl::Underlying<T> _start = Start;
>> or
>> static constexpr EnumeratorRangeImpl::Underlying<T> _start {Start};
>
> I'd earlier considered requiring the type of Start and End be Underlying<T> rather than convertible to that.  The underlying() function is a partial remnant of that.  I'll remove it.

Using brace initialization is the way to go, as it prevents narrowing.

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

PR: https://git.openjdk.java.net/jdk/pull/1530


More information about the hotspot-dev mailing list