Skip to content

Commit

Permalink
return early
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Mar 15, 2024
1 parent 1d4415b commit cd77b05
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ private static EntryComparator getEntryComparator() {
private static List<BibEntryDiff> compareEntries(List<BibEntry> originalEntries, List<BibEntry> newEntries, BibDatabaseMode mode) {
List<BibEntryDiff> differences = new ArrayList<>();

// Prevent IndexOutOfBoundException
if (newEntries.isEmpty()) {
return differences;
}

// Create a HashSet where we can put references to entries in the new
// database that we have matched. This is to avoid matching them twice.
Set<Integer> used = new HashSet<>(newEntries.size());
Expand Down Expand Up @@ -88,11 +93,6 @@ private static List<BibEntryDiff> compareEntries(List<BibEntry> originalEntries,
}
}
}

// Prevent IndexOutOfBoundException
if (newEntries.isEmpty()) {
return differences;
}
BibEntry bestEntry = newEntries.get(bestMatchIndex);
if (bestMatch > MATCH_THRESHOLD
|| hasEqualCitationKey(originalEntry, bestEntry)
Expand Down

0 comments on commit cd77b05

Please sign in to comment.