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:
@@ -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
|
||||
|
Reference in New Issue
Block a user