Skip to content

Commit a6e51e6

Browse files
Vladimir Kotalahornace
authored andcommitted
avoid constructing duplicate list of renamed files
1 parent 2525035 commit a6e51e6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/FileHistoryCache.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.Collections;
4848
import java.util.Date;
4949
import java.util.HashMap;
50-
import java.util.HashSet;
5150
import java.util.List;
5251
import java.util.ListIterator;
5352
import java.util.Map;
@@ -434,7 +433,6 @@ public void store(History history, Repository repository, String tillRevision) t
434433

435434
HashMap<String, List<HistoryEntry>> map = new HashMap<>();
436435
HashMap<String, Boolean> acceptanceCache = new HashMap<>();
437-
Set<String> renamedFiles = new HashSet<>();
438436

439437
/*
440438
* Go through all history entries for this repository (acquired through
@@ -496,7 +494,6 @@ public void store(History history, Repository repository, String tillRevision) t
496494
for (Map.Entry<String, List<HistoryEntry>> map_entry : map.entrySet()) {
497495
try {
498496
if (handleRenamedFiles && isRenamedFile(map_entry.getKey(), repository, history)) {
499-
renamedFiles.add(map_entry.getKey());
500497
continue;
501498
}
502499
} catch (IOException ex) {
@@ -516,7 +513,7 @@ public void store(History history, Repository repository, String tillRevision) t
516513
return;
517514
}
518515

519-
storeRenamed(renamedFiles, repository, tillRevision);
516+
storeRenamed(history.getRenamedFiles(), repository, tillRevision);
520517

521518
finishStore(repository, latestRev);
522519
}
@@ -532,7 +529,8 @@ public void storeRenamed(Set<String> renamedFiles, Repository repository, String
532529
return;
533530
}
534531

535-
renamedFiles = renamedFiles.stream().filter(f -> new File(env.getSourceRootPath() + f).exists()).
532+
renamedFiles = renamedFiles.stream().map(e -> repository.getDirectoryNameRelative() + File.separator + e).
533+
filter(f -> new File(env.getSourceRootPath() + f).exists()).
536534
collect(Collectors.toSet());
537535
LOGGER.log(Level.FINE, "Storing history for {0} renamed files in repository ''{1}''",
538536
new Object[]{renamedFiles.size(), repository.getDirectoryName()});

0 commit comments

Comments
 (0)