commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Sell <christian.s...@netcologne.de>
Subject Re: [jelly] code question
Date Fri, 17 Jan 2003 15:39:51 GMT
James Strachan wrote:
> From: "Christian Sell" <christian.sell@netcologne.de>
> 
>>Hello,
>>
>>in several places in class TagLibrary, I see code like the following:
>>
>>         Object value = tags.get(name);
>>         if (value instanceof Class) {
>>             Class type = (Class) value;
>>             if ( type != null ) {
>>                 return TagScript.newInstance(type);
>>             }
>>
>>
>>my question is: doesnt "value instanceof Class" always return false if
>>value is null? Isnt the null check therefore redundant?
> 
> 
> You're absolutely right. The second if (type != null) is completely
> redundant and can be safely removed.
> 
> 
>>If that is true, the lines
>>
>>         Class type = (Class) tags.get(name);
>>         if ( type != null ) {
>>             return (Tag) type.newInstance();
>>         }
>>
>>in method createTag() are also redundant.
> 
> 
> Yes; those look like the old code, before the TagFactory interface came
> along and it looks like those should have been zapped but have been left by
> accident.
> 
> 
> I've applied your suggestions to TagLibrary.java - that was the code you
> were talking about right? Was there any other place where you saw similar
> redundancies?

not for now. I'll shout if I encounter more

> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.org>
> 
> 



Mime
View raw message