hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1044411
Date Fri, 10 Dec 2010 19:30:16 GMT
On 10 December 2010 18:20, Oleg Kalnichevski <olegk@apache.org> wrote:
> On Fri, 2010-12-10 at 17:15 +0000, sebb wrote:
>> > +    public final boolean equals(Object obj) {
>> > +        if (obj == null) return false;
>>
>> That null check not necessary, because null fails the instanceof check.
>>
>
> I think it saves one comparison operation.

Also, I forgot to say that unless obj is often null, it would be
better to do the self-equality check first.

> Feel free to remove it, but
> ideally all other classes (and they are really a few) should be changed
> as well

OK, I'll see about working my way through them.

>> > +        if (this == obj) return true;
>> > +        if (obj instanceof HttpRoute) {
>> > +            HttpRoute that = (HttpRoute) obj;
>> > +            return LangUtils.equals(this.targetHost, that.targetHost)
&&
>> > +                LangUtils.equals(this.localAddress, that.localAddress)
&&
>>
>> That's a lot neater than the null checks.
>>
>
> That is precisely the intent of LangUtils ;-)
>
> cheers
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message