[gui] Add IndexColorModel methods
Mark Wielaard
mark@klomp.org
Thu Sep 30 14:49:00 GMT 2004
Hi,
On Tue, 2004-09-28 at 03:04, Jerry Quinn wrote:
> + private BigInteger validBits = new BigInteger("0");
>
[...]
> +
> + // Generate a bigint with 1's for every pixel
> + validBits.setBit(size);
> + validBits.subtract(new BigInteger("1"));
>
Note that there is BigInteger.ZERO and BigInteger.ONE which you can use
here so you don't have to create a new object. Also the static method
BigInteger.valueOf(long) is preferred since it can return a pre-existing
BigInteger so no new object needs to be created.
You can do this because BigIntegers are immutable. This also means that
you have to be careful in this code and notice that methods like
setBit() and substract() don't change the BigInteger they are called on,
but return a new BigInteger. There are a couple of places in this code
that should be written like: validBits = validBits.setBit(size);
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040930/98d45b27/attachment.sig>
More information about the Java-patches
mailing list