This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: BigInteger patch (long)


Raif S. Naffah wrote:
hello there,

the following is the diff for a modified BigInteger:

* merged make(long) and valueOf(long), into the latter.
* reduced the use of extraneous variables in the recursive calls to
  euclidInv(BigInteger, BigInteger, BigInteger) by implementing
  Per Bothner's earlier suggestion.  the method has now 3 additional
  BigInteger args for use as temp vars.
* reduced the returned value of euclidInv(int, int, int) to an array
  of just 2 ints rather than 3.
* performance improvement of the isProbablePrime() method, including
  among other things, a parameterised number of iterations based on the
  user-specified 'certainty' argument and the bit-length of the mpi to
  test.  a simple test i wrote shows a clear improvement --the current
  implementation averages 1258ms compared to 112ms for the new one
  (timing for 512-bit primes, on a 1700+ athlon-xp with jdk1.3.1_06).
  btw, the jdk 1.3.1 gives almost the same figures.
* removed some unused methods and local variables.
* updated the copyright dates.
A meta-comment:  This is a number of independent changes.  In
the future, it is better if you can submit them individually.

Of course I'm not qualified to judge the euclidInv and
isProbablePrime algorithms, and I didn't really more than
glance at them.  And generally, I didn't "audit" the
patch, just check for sanity.

I did note these nits:

Just delete these lines - unless you think they're helpful:

//         BigInteger tmp = x; x = y; y = tmp;

//        BigInteger xy2 = new BigInteger();
//        euclidInv(y, rem, quot, xy0, xy1, xy2);

In private static final int gcd(int a, int b) I prefer the
older style with two local tmp variables - I prefer to
keep local declarations local, and to combine initialization
with declaration.  (It seems you generally do, too.)

Otherwise it looks good to me.  Thanks!  If you have CVS
acces, please check it in.
--
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]