lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: svn-commit: 168449 FSDirectory
Date Mon, 06 Jun 2005 18:45:31 GMT
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?

> 2) check for the file extension only without using the "."

Do you mean something like:

   String ext = IndexReader.FILENAME_EXTENSIONS[i];
   if (name.endsWith(ext)
       && name.length >= ext.length()+1
       && '.' == name.charAt(name.length()-(ext.length()+1))) {
     ...
   }

I don't see how this works with (1) above.  My guess is that (1) alone 
would be fastest, even though it still allocates objects.

Also, as mentioned in another message, I think this class, along with 
other index file name logic, should all move to a single place.

Doug

---------------------------------------------------------------------
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