RFR: 8257912: Convert enum iteration to use range-based for loops [v2]
Ioi Lam
iklam at openjdk.java.net
Thu Dec 10 20:33:14 UTC 2020
> Now that [range-based for loops](https://github.com/openjdk/jdk/pull/1488) are allowed by the [HotSpot Style Guide](https://github.com/openjdk/jdk/blob/52ab72127ddc3ca6575d9d58503ec39c5dff7ab1/doc/hotspot-style.md), I have converted the more verbose syntax:
>
> for (vmIntrinsicsIterator it = vmIntrinsicsRange.begin(); it != vmIntrinsicsRange.end(); ++it) {
> vmIntrinsicID index = *it;
> nt[as_int(index)] = string;
> }
>
> to
>
> for (vmIntrinsicID index : EnumRange<vmIntrinsicID>{}) {
> nt[as_int(index)] = string;
> }
>
> I also removed the "convenient" declarations such as `vmIntrinsicsRange` and `vmIntrinsicsIterator` -- these are useful only when writing a traditional for loop, and are probably confusing to everyone else. I've left examples in enumIterator.hpp in case anyone wants to write a traditional for loop.
>
> I also added gtest cases for using range-based for loops with `EnumRange<>`.
Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
- Merge branch 'master' into 8257912-range-based-for-loop
- 8257912: Convert enum iteration to use range-based for loops
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/1707/files
- new: https://git.openjdk.java.net/jdk/pull/1707/files/26ad3f0d..ceaebeeb
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=1707&range=01
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=1707&range=00-01
Stats: 15530 lines in 289 files changed: 13089 ins; 1590 del; 851 mod
Patch: https://git.openjdk.java.net/jdk/pull/1707.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/1707/head:pull/1707
PR: https://git.openjdk.java.net/jdk/pull/1707
More information about the hotspot-dev
mailing list