diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-04-13 23:00:53 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2010-04-13 23:00:53 +0200 |
commit | 6da38b9474f943b66c6594c58510aec234742669 (patch) | |
tree | b6f636d8d37f19ad3b5c3fdadf609ac098b40ccd /org.eclipse.jgit | |
parent | d29618dd41d1dd52972524b4e25679bcf7baa39c (diff) | |
download | jgit-6da38b9474f943b66c6594c58510aec234742669.tar.gz jgit-6da38b9474f943b66c6594c58510aec234742669.zip |
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java index 90ac0bf47e..faebbf67cc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDirectory.java @@ -331,18 +331,19 @@ public class RefDirectory extends RefDatabase { } } - 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) { |