ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pe...@apache.org>
Subject Re: [SUBMIT] Selector API Implementation
Date Sun, 13 Jan 2002 23:05:42 GMT
On Mon, 14 Jan 2002 07:52, Magesh Umasankar wrote:
> > About the only modification I would make is to add an initialize or
>
> prepare
>
> > method to the FileSelector.
>
> Do we need an explicit method?  Can't the no-arg constructor be used
> for such things?

no because it has to be after the setOperation and setValue has been called.

> > That way in the selector you wouldn't keep having
> > to do expensive string compares. You could instead do the compare once
> > and cache it in a boolean variable. That should be much faster.
>
> I don't understand how we can cache these comparisons...
> Any code to illsutrate?

void initialize()
{
  if (value == null) {
          throw new NullPointerException("value must not be null.");
  }
  this.equals = peration.equalsIgnoreCase("equals");
  this.filebased = value.equalsIgnoreCase("file");
}

Thus you have removed all the expensive string operations from isSelected 
which is called for every file. And also check once for value being 
null

-- 
Cheers,

Pete

*------------------------------------------------*
| You can't wake a person who is pretending      |
|       to be asleep. -Navajo Proverb.           |
*------------------------------------------------*

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message