about summary refs log tree commit diff
path: root/absl/base/internal/periodic_sampler.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-11-21T18·30-0800
committerGennadiy Civil <misterg@google.com>2019-11-22T16·35-0500
commit16d9fd58a51c6083234e2e9f8f50e49ed5ed02e4 (patch)
treec4d5da856d0ee16401bb6d9694c998e51b2f604c /absl/base/internal/periodic_sampler.cc
parentbcaae6009c0833b73c6fa7bdd972921d8081a724 (diff)
Export of internal Abseil changes
--
db8dbd0e8a7b0125a4819dfc81c9bd2496849c71 by Abseil Team <absl-team@google.com>:

Create GetSkipCount() and GetStride() methods and add rounding bias correction.

PiperOrigin-RevId: 281780897
GitOrigin-RevId: db8dbd0e8a7b0125a4819dfc81c9bd2496849c71
Change-Id: I56a97288b1cb38a9357c065747f8d9bc4b187fee
Diffstat (limited to 'absl/base/internal/periodic_sampler.cc')
-rw-r--r--absl/base/internal/periodic_sampler.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/absl/base/internal/periodic_sampler.cc b/absl/base/internal/periodic_sampler.cc
index 69656c8a0fbe..87c3c85ae3e2 100644
--- a/absl/base/internal/periodic_sampler.cc
+++ b/absl/base/internal/periodic_sampler.cc
@@ -22,7 +22,7 @@ namespace absl {
 namespace base_internal {
 
 int64_t PeriodicSamplerBase::GetExponentialBiased(int period) noexcept {
-  return rng_.Get(period);
+  return rng_.GetStride(period);
 }
 
 bool PeriodicSamplerBase::SubtleConfirmSample() noexcept {
@@ -36,13 +36,14 @@ bool PeriodicSamplerBase::SubtleConfirmSample() noexcept {
 
   // Check if this is the first call to Sample()
   if (ABSL_PREDICT_FALSE(stride_ == 1)) {
-    stride_ = static_cast<uint64_t>(-1 - GetExponentialBiased(current_period));
+    stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period));
     if (static_cast<int64_t>(stride_) < -1) {
       ++stride_;
       return false;
     }
   }
-  stride_ = static_cast<uint64_t>(-1 - GetExponentialBiased(current_period));
+
+  stride_ = static_cast<uint64_t>(-GetExponentialBiased(current_period));
   return true;
 }