136 const auto toInt = [](
const size_t v) {
return static_cast<int>(std::min(
v,
static_cast<size_t>(std::numeric_limits<int>::max()))); };
137 const int initialCapacity = toInt(estimator.capacity(
key, scale));
138 int capacity = std::max(initialCapacity, toInt(floorCapacity));
140 bool overflowed =
false;
141 bool needsRetry =
false;
143 const int attemptCapacity =
capacity;
144 emitted = emit(attemptCapacity);
145 needsRetry = emitted > attemptCapacity;
146 overflowed |= needsRetry;
148 }
while (needsRetry);
149 estimator.update(
key, scale, emitted, initialCapacity, overflowed,
false);