commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [jelly] code question
Date Fri, 17 Jan 2003 06:58:18 GMT
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?

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

Mime
View raw message