mirror of
https://github.com/zxing/zxing.git
synced 2025-01-11 19:27:29 -08:00
fix container inefficiency in RSSExpandedReader.java (#1782)
This commit is contained in:
parent
c77778ee03
commit
accc4d5ead
|
@ -222,25 +222,24 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||||
private List<ExpandedPair> checkRows(List<ExpandedRow> collectedRows, int currentRow) throws NotFoundException {
|
private List<ExpandedPair> checkRows(List<ExpandedRow> collectedRows, int currentRow) throws NotFoundException {
|
||||||
for (int i = currentRow; i < rows.size(); i++) {
|
for (int i = currentRow; i < rows.size(); i++) {
|
||||||
ExpandedRow row = rows.get(i);
|
ExpandedRow row = rows.get(i);
|
||||||
this.pairs.clear();
|
|
||||||
for (ExpandedRow collectedRow : collectedRows) {
|
|
||||||
this.pairs.addAll(collectedRow.getPairs());
|
|
||||||
}
|
|
||||||
this.pairs.addAll(row.getPairs());
|
this.pairs.addAll(row.getPairs());
|
||||||
|
int addSize = row.getPairs().size();
|
||||||
|
|
||||||
if (isValidSequence(this.pairs, false)) {
|
if (isValidSequence(this.pairs, false)) {
|
||||||
if (checkChecksum()) {
|
if (checkChecksum()) {
|
||||||
return this.pairs;
|
return this.pairs;
|
||||||
}
|
}
|
||||||
|
collectedRows.add(row);
|
||||||
List<ExpandedRow> rs = new ArrayList<>(collectedRows);
|
|
||||||
rs.add(row);
|
|
||||||
try {
|
try {
|
||||||
// Recursion: try to add more rows
|
// Recursion: try to add more rows
|
||||||
return checkRows(rs, i + 1);
|
return checkRows(collectedRows, i + 1);
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
// We failed, try the next candidate
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue