Optimize ref scanning
We can avoid one stat call by trying to perform a directory listing without checking if the reference File is a directory. Attempting a directory listing is defined to return. The other case for null returns from list is when an I/O error occcurs. Both cases are now intepreted as a possible plain reference. I/O errors when reading plain references will be handled (ignored) in scanRef(). Change-Id: I9906ed8c42eab4d6029c781aab87b3b07c1a1d2c Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
This commit is contained in:
parent
d29618dd41
commit
6da38b9474
|
@ -331,18 +331,19 @@ void scan(String prefix) {
|
|||
}
|
||||
}
|
||||
|
||||
private void scanTree(String prefix, File dir) {
|
||||
private boolean scanTree(String prefix, File dir) {
|
||||
final String[] entries = dir.list(LockFile.FILTER);
|
||||
if (entries != null && 0 < entries.length) {
|
||||
if (entries == null) // not a directory or an I/O error
|
||||
return false;
|
||||
if (0 < entries.length) {
|
||||
Arrays.sort(entries);
|
||||
for (String name : entries) {
|
||||
File e = new File(dir, name);
|
||||
if (e.isDirectory())
|
||||
scanTree(prefix + name + '/', e);
|
||||
else
|
||||
if (!scanTree(prefix + name + '/', e))
|
||||
scanOne(prefix + name);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void scanOne(String name) {
|
||||
|
|
Loading…
Reference in New Issue