Skip to content

Commit 53c21ad

Browse files
azakkermanahornace
authored andcommitted
Speed up IndexDatabase.accept() by avoiding history lookup for files if unversioned files are allowed by the config.
1 parent cc8c6f3 commit 53c21ad

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -843,19 +843,20 @@ private boolean accept(File file, AcceptSymlinkRet ret) {
843843
return true;
844844
}
845845

846-
if (HistoryGuru.getInstance().hasHistory(file)) {
847-
// versioned files should always be accepted
848-
return true;
849-
}
850846

851-
// this is an unversioned file, check if it should be indexed
852847
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
853-
boolean res = !env.isIndexVersionedFilesOnly();
854-
if (!res) {
855-
LOGGER.log(Level.FINER, "not accepting unversioned {0}",
856-
absolutePath);
848+
// Lookup history if indexing versioned files only.
849+
// Skip the lookup entirely (which is expensive) if unversioned files are allowed
850+
if (env.isIndexVersionedFilesOnly()) {
851+
if (HistoryGuru.getInstance().hasHistory(file)) {
852+
// versioned files should always be accepted
853+
return true;
854+
}
855+
LOGGER.log(Level.FINER, "not accepting unversioned {0}", absolutePath);
856+
return false;
857857
}
858-
return res;
858+
// unversioned files are allowed
859+
return true;
859860
}
860861

861862
/**

0 commit comments

Comments
 (0)