Browse Source

Use the new FS.exists method in commonly occuring places

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

Change-Id: Id2057cb2cfcb46e94ff954483ce23f9c4a7edc5e
stable-3.3
Robin Rosenberg 12 years ago committed by Matthias Sohn
parent
commit
5ef6d69532
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java
  5. 2
      org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java

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

4
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

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

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -639,7 +639,7 @@ public class RefDirectory extends RefDatabase {
for (String refName : refs) { for (String refName : refs) {
// Lock the loose ref // Lock the loose ref
File refFile = fileFor(refName); File refFile = fileFor(refName);
if (!refFile.exists()) if (!fs.exists(refFile))
continue; continue;
LockFile rLck = new LockFile(refFile, LockFile rLck = new LockFile(refFile,
parent.getFS()); parent.getFS());

2
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/FileTreeIterator.java

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

2
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java

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

Loading…
Cancel
Save