Skip to content

Commit

Permalink
fix container inefficiency in RSSExpandedReader.java
Browse files Browse the repository at this point in the history
  • Loading branch information
cinsttool committed Apr 2, 2024
1 parent c77778e commit e1390f1
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,24 @@ private List<ExpandedPair> checkRows(boolean reverse) {
private List<ExpandedPair> checkRows(List<ExpandedRow> collectedRows, int currentRow) throws NotFoundException {
for (int i = currentRow; i < rows.size(); i++) {
ExpandedRow row = rows.get(i);
this.pairs.clear();
for (ExpandedRow collectedRow : collectedRows) {
this.pairs.addAll(collectedRow.getPairs());
}
this.pairs.addAll(row.getPairs());
int addSize = row.getPairs().size();

if (isValidSequence(this.pairs, false)) {
if (checkChecksum()) {
return this.pairs;
}

List<ExpandedRow> rs = new ArrayList<>(collectedRows);
rs.add(row);
collectedRows.add(row);
try {
// Recursion: try to add more rows
return checkRows(rs, i + 1);
return checkRows(collectedRows, i + 1);
} catch (NotFoundException e) {
// We failed, try the next candidate
collectedRows.remove(collectedRows.size() - 1);
this.pairs.subList(this.pairs.size() - addSize, this.pairs.size()).clear();
}
} else {
this.pairs.subList(this.pairs.size() - addSize, this.pairs.size()).clear();
}
}

Expand Down

0 comments on commit e1390f1

Please sign in to comment.