Optimize RegexFilePredicate for common matches

A common pattern is file:^some/directory/.*, which we can efficiently
match by sorting the paths and using the common prefix to narrow our
search space to only the portion that has a chance of matching with us.

Change-Id: I12cad5e5d5e8af3e1fe902b1e70828491e5cc048
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-08-21 15:37:57 -07:00
parent 3b175d5800
commit 8c11f0c458
4 changed files with 148 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -54,7 +55,9 @@ public class CommentSender extends ReplyToChangeSender {
paths.add(p.getFileName());
}
}
changeData.setCurrentFilePaths(paths);
String[] names = paths.toArray(new String[paths.size()]);
Arrays.sort(names);
changeData.setCurrentFilePaths(names);
}
@Override