You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2010/12/10 19:20:21 UTC
Re: svn commit: r1044411
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. Feel free to remove it, but
ideally all other classes (and they are really a few) should be changed
as well
> > + 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
Re: svn commit: r1044411
Posted by sebb <se...@gmail.com>.
On 10 December 2010 18:20, Oleg Kalnichevski <ol...@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