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.modInverse() fix


Tom Tromey wrote:
"Per" == Per Bothner <per@bothner.com> writes:

Per> Would it make sense to do:
Per>            rem = rem.canonicalize();
Per>            quot = quot.canonicalize();
Per> It probably doesn't matter.

Are rem and quot guaranteed not to be small?
If so, at least a comment is warranted.
If not, the above must be done.
Not necessarirly.  I don't think canonicaliztion of small
integers is required for correctness, just (space) effiency.
And of course if you're going to modify the BigInteger,
then it would be wrong to use one of the smallFixNums.

Per> Instead of allocating a BigInteger at each level of
Per> recursion, maybe you could modify euclidInv to:

The code already has a FIXME about its inefficient use of memory.  So
I think making this change isn't a requirement for the patch.  OTOH,
if Mark or Raif want to do it, that would be great.
I didn't mean it as a requirement - only a suggestion.

Of course I'm even more concerned about the serialization
causing all the wasted extra fields.  I wish somebody who
has a vague idea of the serialization protocol could just
fix this.  Just replace the otherwise-unused fields with
local variables in readObject/writeObject, and replace the
calls to defaultReadObject and defaultWriteObject, with calls
to write those variables.
--
	--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]