Use the new FS.exists method in commonly occuring places

Allegedly this should improve performance, but I could not see it.

Change-Id: Id2057cb2cfcb46e94ff954483ce23f9c4a7edc5e
This commit is contained in:
Robin Rosenberg 2013-02-04 01:11:29 +01:00 committed by Matthias Sohn
parent 239f237be2
commit 5ef6d69532
5 changed files with 8 additions and 6 deletions

View File

@ -45,6 +45,8 @@
import java.io.File;
import org.eclipse.jgit.util.FS;
/**
* Caches when a file was last read, making it possible to detect future edits.
* <p>
@ -81,7 +83,7 @@ public class FileSnapshot {
public static final FileSnapshot MISSING_FILE = new FileSnapshot(0, 0) {
@Override
public boolean isModified(File path) {
return path.exists();
return FS.DETECTED.exists(path);
}
};

View File

@ -180,7 +180,7 @@ public final File getDirectory() {
@Override
public boolean exists() {
return objects.exists();
return fs.exists(objects);
}
@Override
@ -566,7 +566,7 @@ InsertLooseObjectResult insertUnpackedObject(File tmp, ObjectId id,
}
final File dst = fileFor(id);
if (dst.exists()) {
if (fs.exists(dst)) {
// We want to be extra careful and avoid replacing an object
// that already exists. We can't be sure renameTo() would
// fail on all platforms if dst exists, so we check first.

View File

@ -639,7 +639,7 @@ public void pack(List<String> refs) throws IOException {
for (String refName : refs) {
// Lock the loose ref
File refFile = fileFor(refName);
if (!refFile.exists())
if (!fs.exists(refFile))
continue;
LockFile rLck = new LockFile(refFile,
parent.getFS());

View File

@ -168,7 +168,7 @@ public FileEntry(final File f, FS fs) {
file = f;
if (f.isDirectory()) {
if (new File(f, Constants.DOT_GIT).exists())
if (fs.exists(new File(f, Constants.DOT_GIT)))
mode = FileMode.GITLINK;
else
mode = FileMode.TREE;

View File

@ -1154,7 +1154,7 @@ IgnoreNode load() throws IOException {
private void loadRulesFromFile(IgnoreNode r, File exclude)
throws FileNotFoundException, IOException {
if (exclude.exists()) {
if (FS.DETECTED.exists(exclude)) {
FileInputStream in = new FileInputStream(exclude);
try {
r.parse(in);