Philipp Meier wrote:

> On Fri, Jan 26, 2001 at 09:33:15AM -0800, Jeffrey Wescott wrote:
> 
>> I think that the following should be okay:
>> 
>> public boolean equals(Object o) {
>>     try {
>>         UserListPK in = (UserListPK)o;
>>         return ( userID.equals(in.userID) && listID.equals(in.listID) );
>>     } catch (ClassCastException e) {
>>         return false;
>>     }
>> }
> 
> 
> Doesn't imply a try-catch clause a performancy penalty? IMHO this should be
> faster:

Why would it? In the unexceptional case all you get is an extra goto (or 
something, depending on how smart the compiler is).

> return ( (o instanceof UserListPK ) ?
>         userID.equals((UserListPK) o.userID) && listID.equals((UserListPK) o.listID) 
>:
>         false
>       );

But in this version you have an extra cast which definitely is a 
performance problem.

> My $0.02,
>       -billy.

Your change and best regards,

Toby.



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to