Integrated: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Thu Aug 12 10:07:29 UTC 2021


On Tue, 10 Aug 2021 13:16:42 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

> The code in `Integer.decode()` and `Long.decode()` might allocate two instances of Integer/Long for the negative values less than -127:
> 
> Integer result;
> 
> result = Integer.valueOf(nm.substring(index), radix);
> result = negative ? Integer.valueOf(-result.intValue()) : result;
> 
> To avoid this we can declare 'result' as `int` and use `Integer.parseInt()` method. Same applicable for `Long` and some other classes.

This pull request has now been integrated.

Changeset: b29fbad9
Author:    Sergey Tsypanov <sergei.tsypanov at yandex.ru>
Committer: Claes Redestad <redestad at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/b29fbad940808c59f30e60222a9ca7a23c8e54b9
Stats:     32 lines in 6 files changed: 19 ins; 1 del; 12 mod

8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable

Reviewed-by: redestad

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

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


More information about the security-dev mailing list