Skip to content

Commit

Permalink
initial ArraySize
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch committed Oct 2, 2023
1 parent a78f958 commit fa718db
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static io.servicetalk.concurrent.api.SubscriberApiUtils.wrapNull;
import static io.servicetalk.concurrent.internal.ConcurrentUtils.releaseLock;
import static io.servicetalk.concurrent.internal.ConcurrentUtils.tryAcquireLock;
import static java.lang.Math.min;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater;
Expand Down Expand Up @@ -110,13 +111,14 @@ public static <T> ReplayStrategyBuilder<T> historyTtlBuilder(int historyHint, Du

private static final class MostRecentReplayAccumulator<T> implements ReplayAccumulator<T> {
private final int maxItems;
private final Deque<Object> items = new ArrayDeque<>();
private final Deque<Object> items;

MostRecentReplayAccumulator(final int maxItems) {
if (maxItems <= 0) {
throw new IllegalArgumentException("maxItems: " + maxItems + "(expected >0)");
}
this.maxItems = maxItems;
items = new ArrayDeque<>(min(maxItems, 16));
}

@Override
Expand Down Expand Up @@ -151,7 +153,7 @@ private static final class LazyTimeLimitedReplayAccumulator<T> implements Replay
this.maxItems = maxItems;
this.executor = requireNonNull(executor);
this.ttlNanos = ttl.toNanos();
items = new ArrayDeque<>();
items = new ArrayDeque<>(min(maxItems, 16));
}

@Override
Expand Down

0 comments on commit fa718db

Please sign in to comment.