Re: RFR: 8315585: Optimization for new BigDecimal(String)

2024-03-11 Thread Shaojin Wen
On Sun, 10 Mar 2024 20:27:56 GMT, Chen Liang wrote: > Good idea! Since we are now maintaining two code paths, when we update one, > we might forget about the other; is it possible to create another interal > constructor that takes a `CharSequence`, so we can pass the string in > directly, and

Re: RFR: 8315585: Optimization for new BigDecimal(String)

2024-03-11 Thread Shaojin Wen
On Sun, 10 Mar 2024 16:11:12 GMT, Shaojin Wen wrote: > The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is g

Re: RFR: 8315585: Optimization for new BigDecimal(String)

2024-03-11 Thread Chen Liang
On Sun, 10 Mar 2024 16:11:12 GMT, Shaojin Wen wrote: > The current BigDecimal(String) constructor calls String#toCharArray, which > has a memory allocation. > > > public BigDecimal(String val) { > this(val.toCharArray(), 0, val.length()); // allocate char[] > } > > > When the length is g