Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-13 Thread Claes Redestad
On Fri, 13 Aug 2021 13:16:04 GMT, SkateScout wrote: > OK even if we keep out the edge case in the try block the > "parseLong(nm.substring(index), radix)" could be replaced as already > mentioned with parseLong(nm. index, nm.length(), radix) I think it already was: https://github.com/openjdk/

Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-13 Thread SkateScout
On Tue, 10 Aug 2021 21:06:00 GMT, Сергей Цыпанов 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 = n

Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-13 Thread Claes Redestad
On Thu, 12 Aug 2021 21:26:08 GMT, SkateScout wrote: > Hi, > i check Long.java line 1301...1311 and i am not sure if this code is really > good. > > 1. If negative is false the whole part ends with two times the same > substring and this implies the same error. > > 2. If negative is

Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-13 Thread SkateScout
On Tue, 10 Aug 2021 21:06:00 GMT, Сергей Цыпанов 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 = n

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

2021-08-10 Thread Thomas Lußnig
Hi, i wonder why all usages of decode should be replaced. Since Integer.valueOf(text,radix) = Integer.valueOf(Ineger.parseInt(text,radix)) The double allocation with result = Integer.valueOf(nm.substring(index), radix); result = negative ? Integer.valueOf(-result.intValue()) : result; could

Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-10 Thread Claes Redestad
On Tue, 10 Aug 2021 21:06:00 GMT, Сергей Цыпанов 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 = n

Re: RFR: 8267844: Replace Integer/Long.valueOf() with Integer/Long.parse*() where applicable [v2]

2021-08-10 Thread Сергей Цыпанов
> 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 av

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

2021-08-10 Thread Сергей Цыпанов
On Tue, 10 Aug 2021 17:39:01 GMT, Сергей Цыпанов wrote: >> src/java.base/share/classes/java/lang/Integer.java line 1450: >> >>> 1448: >>> 1449: try { >>> 1450: result = parseInt(nm.substring(index), radix); >> >> Possibly a follow-up, but I think using `parseInt/-Long(nm,

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

2021-08-10 Thread Сергей Цыпанов
On Tue, 10 Aug 2021 14:56:11 GMT, Claes Redestad 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 = ne

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

2021-08-10 Thread Claes Redestad
On Tue, 10 Aug 2021 13:16:42 GMT, Сергей Цыпанов 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

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

2021-08-10 Thread Сергей Цыпанов
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 de