mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
set initial capacity to minimum if unknown capacity
This commit is contained in:
@@ -12,11 +12,11 @@ public class FixedSizeSortedSet<E> extends PriorityQueue<E> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final Comparator<? super E> comparator;
|
private final Comparator<? super E> comparator;
|
||||||
private final int maxSize;
|
private final int capacity;
|
||||||
|
|
||||||
public FixedSizeSortedSet(int maxSize, Comparator<? super E> comparator) {
|
public FixedSizeSortedSet(int capacity, Comparator<? super E> comparator) {
|
||||||
super(maxSize, comparator);
|
super(Math.max(1, capacity), comparator);
|
||||||
this.maxSize = maxSize;
|
this.capacity = capacity < 0 ? Integer.MAX_VALUE : capacity;
|
||||||
this.comparator = comparator;
|
this.comparator = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public class FixedSizeSortedSet<E> extends PriorityQueue<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFull() {
|
public boolean isFull() {
|
||||||
return size() == maxSize;
|
return size() == capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
|
|||||||
Comparator<FeedEntryStatus> comparator = order == ReadingOrder.desc ? STATUS_COMPARATOR_DESC
|
Comparator<FeedEntryStatus> comparator = order == ReadingOrder.desc ? STATUS_COMPARATOR_DESC
|
||||||
: STATUS_COMPARATOR_ASC;
|
: STATUS_COMPARATOR_ASC;
|
||||||
FixedSizeSortedSet<FeedEntryStatus> set = new FixedSizeSortedSet<FeedEntryStatus>(
|
FixedSizeSortedSet<FeedEntryStatus> set = new FixedSizeSortedSet<FeedEntryStatus>(
|
||||||
capacity < 0 ? Integer.MAX_VALUE : capacity, comparator);
|
capacity, comparator);
|
||||||
for (FeedSubscription sub : subscriptions) {
|
for (FeedSubscription sub : subscriptions) {
|
||||||
Date last = (order != null && set.isFull()) ? set.last()
|
Date last = (order != null && set.isFull()) ? set.last()
|
||||||
.getEntryUpdated() : null;
|
.getEntryUpdated() : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user