Integrated: 8298380: Clean up redundant array length checks in JDK code base

Sergey Tsypanov stsypanov at openjdk.org
Fri Dec 9 12:54:50 UTC 2022


On Thu, 8 Dec 2022 12:37:17 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

> Newer version of IntelliJ IDEA introduces new [inspection](https://youtrack.jetbrains.com/issue/IDEA-301797/IDEA-should-report-redundant-array-length-check-in-certain-cases) detecting redundant array length check in snippets like
> 
> <T> void iterate(T[] items) {
>   if (items.length == 0) {
>     return;
>   }
>   for (T item : items) {
>     //...
>   }
> }
> 
> Here
> 
> if (items.length == 0) {
>   return;
> }
> 
> is redundant and can be removed as length check is performed by for-each loop.

This pull request has now been integrated.

Changeset: e3c6cf8e
Author:    Sergey Tsypanov <stsypanov at openjdk.org>
Committer: Julian Waters <jwaters at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e3c6cf8eaf931d9eb46b429a5ba8d3bbded3728a
Stats:     51 lines in 8 files changed: 0 ins; 14 del; 37 mod

8298380: Clean up redundant array length checks in JDK code base

Reviewed-by: dholmes, amenkov, serb, vtewari

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

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


More information about the serviceability-dev mailing list