Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-20 Thread Raffaello Giulietti
On Fri, 16 May 2025 10:10:28 GMT, fabioromano1 wrote: >> There are problems with the `test/jdk/java/math/BigInteger` tests. Can you >> please crosscheck? > >> There are problems with the `test/jdk/java/math/BigInteger` tests. Can you >> please crosscheck? > > @rgiulietti It seems there is a s

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v18]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: A minor change - Changes: - all: https://g

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v17]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Use bitwise or instead of + in longValue() -

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v16]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Some code simplifications for *ValueExact() -

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v15]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Simplify two's complement in makePositive(int[])

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v14]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Avoid redundance of stripLeadingZeroInts() -

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v13]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Small code simplifications - Changes: - al

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v12]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Revert "Removed redundant code for choosing division's alg

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v11]

2025-05-20 Thread Raffaello Giulietti
On Tue, 20 May 2025 13:20:10 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v11]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Removed redundant code for choosing division's algorithm l

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v10]

2025-05-20 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Small code simplifications - Changes: - al

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-20 Thread Raffaello Giulietti
On Fri, 16 May 2025 10:10:28 GMT, fabioromano1 wrote: >> There are problems with the `test/jdk/java/math/BigInteger` tests. Can you >> please crosscheck? > >> There are problems with the `test/jdk/java/math/BigInteger` tests. Can you >> please crosscheck? > > @rgiulietti It seems there is a s

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-19 Thread fabioromano1
On Mon, 19 May 2025 17:34:16 GMT, Raffaello Giulietti wrote: >> Yes, but perhaps in the current version it's more clear what is the returned >> value according to the condition. > > One could see the suggested variant as "return magBitLength(), except for a > corrective term in case blah blah.

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-19 Thread Raffaello Giulietti
On Mon, 19 May 2025 17:16:58 GMT, fabioromano1 wrote: >> I think the suggestion is fine. > > Yes, but perhaps in the current version it's more clear what is the returned > value according to the condition. One could see the suggested variant as "return magBitLength(), except for a corrective t

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-19 Thread fabioromano1
On Mon, 19 May 2025 15:50:10 GMT, Raffaello Giulietti wrote: >> What is the usefulness of doing `int[] mag = this.mag;` at line 3856, since >> `bitLength()` does not access to `static` fields and `BigInteger` is not >> threadsafe, and therefore no race conditions occur? > > I think the suggest

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v9]

2025-05-19 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Removed numberOfTrailingZeros() as a duplicate of the cach

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-19 Thread Raffaello Giulietti
On Fri, 16 May 2025 13:30:01 GMT, fabioromano1 wrote: >> src/java.base/share/classes/java/math/BigInteger.java line 3860: >> >>> 3858: && Integer.lowestOneBit(mag[0]) == mag[0] >>> 3859: && numberOfTrailingZeroInts() == mag.length - 1 >>> 3860: ? magBi

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v8]

2025-05-19 Thread fabioromano1
On Mon, 19 May 2025 15:03:51 GMT, Raffaello Giulietti wrote: >> src/java.base/share/classes/java/math/BigInteger.java line 5034: >> >>> 5032: */ >>> 5033: private byte[] magSerializedForm() { >>> 5034: byte[] result = new byte[(magBitLength() + 7) >>> 3]; >> >> I think there's

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v8]

2025-05-19 Thread Raffaello Giulietti
On Mon, 19 May 2025 15:02:57 GMT, Raffaello Giulietti wrote: >> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> An optimization > > src/java.base/share/classes/java/math/BigInteger.java line 5034: > >> 5032: */ >> 503

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v8]

2025-05-19 Thread Raffaello Giulietti
On Fri, 16 May 2025 11:10:12 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-16 Thread fabioromano1
On Thu, 15 May 2025 22:43:54 GMT, Shaojin Wen wrote: >> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> make magBitLength() an instance method > > src/java.base/share/classes/java/math/BigInteger.java line 3860: > >> 3858:

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-16 Thread fabioromano1
On Thu, 15 May 2025 15:37:39 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-16 Thread Raffaello Giulietti
On Fri, 16 May 2025 11:43:18 GMT, fabioromano1 wrote: >> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> make magBitLength() an instance method > > src/java.base/share/classes/java/math/BigInteger.java line 3619: > >> 3617:

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v8]

2025-05-16 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: An optimization - Changes: - all: https://

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v7]

2025-05-16 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Correct bug in shiftRight - Changes: - all

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-16 Thread fabioromano1
On Thu, 15 May 2025 22:03:40 GMT, Raffaello Giulietti wrote: > There are problems with the `test/jdk/java/math/BigInteger` tests. Can you > please crosscheck? @rgiulietti It seems there is a slowdown in the creation of large pseudoprimes, maybe due to `BitSieve` methods. - PR C

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-15 Thread Shaojin Wen
On Thu, 15 May 2025 15:37:39 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-15 Thread Raffaello Giulietti
On Thu, 15 May 2025 15:37:39 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v6]

2025-05-15 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: make magBitLength() an instance method - Cha

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v5]

2025-05-15 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Make javaIncrement(int[]) static - Changes:

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-15 Thread Raffaello Giulietti
On Tue, 13 May 2025 21:24:08 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-15 Thread fabioromano1
On Thu, 15 May 2025 13:51:29 GMT, Raffaello Giulietti wrote: > It cannot be made an instance method, though. There's one usage which needs a > static invocation. @rgiulietti If you are referring to [this invocation](https://github.com/fabioromano1/jdk/blob/5ad26a14049e1765d9ef46f307d723dd4b31

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-15 Thread Raffaello Giulietti
On Tue, 13 May 2025 21:24:08 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-15 Thread fabioromano1
On Thu, 15 May 2025 13:35:29 GMT, Raffaello Giulietti wrote: >> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Update names > > Since you are at it, I'd suggest changing `javaIncrement` to be `static` (no > need to change

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-15 Thread Raffaello Giulietti
On Tue, 13 May 2025 21:24:08 GMT, fabioromano1 wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v4]

2025-05-13 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Update names - Changes: - all: https://git

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v3]

2025-05-13 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: Same optimization of previous commit - Chang

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations [v2]

2025-05-13 Thread fabioromano1
> Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. fabioromano1 has updated the pull request incrementally with one additional commit since the last revision: An optimization - Changes: - all: https://

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
On Sun, 11 May 2025 16:08:25 GMT, fabioromano1 wrote: >> src/java.base/share/classes/java/math/BigInteger.java line 2828: >> >>> 2826: * assuming there are no leading zero ints. >>> 2827: */ >>> 2828: private static int bitLength(int[] val, int len) { >> >> This should really be r

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
On Sun, 11 May 2025 16:12:38 GMT, fabioromano1 wrote: >>> This should really be refactored to an instance method `bitLengthUnsigned` >>> or `magBitCount` >> >> I would prefer `magBitLength` as a name, since `bitCount` is usually >> referred to one's bit count. But before do this, I'd hear the

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
On Sun, 11 May 2025 16:00:55 GMT, Chen Liang wrote: > This should really be refactored to an instance method `bitLengthUnsigned` or > `magBitCount` I would prefer `magBitLength` as a name, since `bitCount` is usually referred to one's bit count. But before do this, I'd hear the opinion of @rgi

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread Chen Liang
On Sat, 10 May 2025 16:41:17 GMT, fabioromano1 wrote: > Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. src/java.base/share/classes/java/math/BigInteger.java line 2828: > 2826: * assuming there are no leading zer

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread Chen Liang
On Mon, 12 May 2025 01:46:25 GMT, David Schlosnagle wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > src/java.base/share/classes/java/math/BigInteger.java line 2642: > >> 2640: } >> 2641:

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
On Mon, 12 May 2025 01:52:51 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/math/BigInteger.java line 2642: >> >>> 2640: } >>> 2641: // (this.abs().bitLength() - 1L) * exponent + 1L > >>> Integer.MAX_VALUE >>> 2642: if (scaleFactor + bitsToShift - exponent >=

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread Raffaello Giulietti
On Mon, 12 May 2025 13:45:08 GMT, fabioromano1 wrote: >> @fabioromano1 While reviewers can of course file JBS issues on behalf of >> contributors, the recommende way is for the latter to file a [bug >> report](https://bugreport.java.com/bugreport/), as they know what they will >> work on bette

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread David Schlosnagle
On Sat, 10 May 2025 16:41:17 GMT, fabioromano1 wrote: > Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. src/java.base/share/classes/java/math/BigInteger.java line 2642: > 2640: } > 2641: // (this.abs()

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread Raffaello Giulietti
On Sat, 10 May 2025 16:41:17 GMT, fabioromano1 wrote: > Some changes in `Biginteger`s' bit operations that increase the code > readability and slightly optimize the execution time. @fabioromano1 While reviewers can of course file JBS issues on behalf of contributors, the recommende way is for

Re: RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
On Mon, 12 May 2025 13:13:36 GMT, Raffaello Giulietti wrote: >> Some changes in `Biginteger`s' bit operations that increase the code >> readability and slightly optimize the execution time. > > @fabioromano1 While reviewers can of course file JBS issues on behalf of > contributors, the recomme

RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations

2025-05-13 Thread fabioromano1
Some changes in `Biginteger`s' bit operations that increase the code readability and slightly optimize the execution time. - Commit messages: - More clear comment - An optimization - Code simplification - Code simplification - Avoiding redundant code - Code simplification - Co