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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to