lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernhard Messer <bmes...@apache.org>
Subject Re: svn-commit: 168449 FSDirectory
Date Tue, 07 Jun 2005 07:13:10 GMT
Doug Cutting wrote:

> Bernhard Messer wrote:
>
>> Therefore i would like to propose two changes:
>> 1) we should store the extension in a hash and not in String[] to 
>> have a faster lookup
>
>
> Do you mean to use something like:
>
> String lastDot = name.lastIndexOf('.');
> if (lastDot >= 0) {
>   String nameExt = name.substring(lastDot+1, name.length());
>   if (FILENAME_EXTENSIONS.get(nameExt)) {
>     ...
>   }
> }
>
> That would allocate a new String in each case, which would be 
> substantially faster.  Is that what you meant?

exactly, that's what i had in mind. I know that we have to allocate a 
new string object for every call, but this must be much cheaper than the 
current implementation which has to walk thru the whole array every time 
the method is called.

Bernhard


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message