RFR: 8274237: Replace 'for' cycles with iterator with enhanced-for in java.base
Andrey Turbanov
github.com+741251+turbanoff at openjdk.java.net
Thu Sep 23 20:52:09 UTC 2021
There are few places in code where manual `for` loop is used with Iterator to iterate over Collection.
Instead of manual `for` cycles it's preferred to use enhanced-for cycle instead: it's less verbose, makes code easier to read and it's less error-prone.
Sometimes we even don't need cycle at all: we can just create one ArrayList as a copy of another.
It doesn't have any performance impact: java compiler generates similar code when compiling enhanced-for cycle.
This is continuation of [JDK-8273261](https://bugs.openjdk.java.net/browse/JDK-8273261)
-------------
Commit messages:
- [PATCH] Replace 'for' cycles with iterator with enhanced-for in java.base
Changes: https://git.openjdk.java.net/jdk/pull/5665/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5665&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8274237
Stats: 32 lines in 4 files changed: 0 ins; 14 del; 18 mod
Patch: https://git.openjdk.java.net/jdk/pull/5665.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/5665/head:pull/5665
PR: https://git.openjdk.java.net/jdk/pull/5665
More information about the security-dev
mailing list