Mark, On 12/4/12 4:21 PM, [email protected] wrote: > + private int hashCode=0; > + // did we compute the hashcode ? > + private boolean hasHashCode = false;
Should hashCode and hasHashCode be volatile?
> // -------------------- Hash code --------------------
>
> + @Override
> + public int hashCode() {
> + if (hasHashCode) {
> + return hashCode;
> + }
> + int code = 0;
> +
> + code = hash();
> + hashCode = code;
> + hasHashCode = true;
> + return code;
> + }
Any particular reason for the dead store of 0 to 'code' local?
In fact, there seems to be much more code in there than necessary. Why not:
> + public int hashCode() {
> + if (hasHashCode) {
> + return hashCode;
> + }
> + hashCode = hash();
> + hasHashCode = true;
> + return hashCode;
-chris
signature.asc
Description: OpenPGP digital signature
