You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2021/08/08 19:43:59 UTC
[commons-rng] 04/07: Precompute size minus 1
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit f205e3fe054872a637f793a96bdcc481851372f8
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sun Aug 8 19:25:16 2021 +0100
Precompute size minus 1
---
.../jmh/sampling/distribution/ZigguratSamplerPerformance.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
index 2bea436..3fc9e1c 100644
--- a/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
+++ b/commons-rng-examples/examples-jmh/src/main/java/org/apache/commons/rng/examples/jmh/sampling/distribution/ZigguratSamplerPerformance.java
@@ -429,8 +429,8 @@ public class ZigguratSamplerPerformance {
* Create N samples from the sampler.
*/
static class SizeNSampler extends SizeSampler {
- /** The number of samples. */
- private final int size;
+ /** The number of samples minus 1. */
+ private final int sizeM1;
/**
* @param delegate the sampler to create the samples
@@ -441,12 +441,12 @@ public class ZigguratSamplerPerformance {
if (size < 1) {
throw new IllegalArgumentException("Size must be above zero: " + size);
}
- this.size = size;
+ this.sizeM1 = size - 1;
}
@Override
public double sample() {
- for (int i = size - 1; i != 0; i--) {
+ for (int i = sizeM1; i != 0; i--) {
delegate.sample();
}
return delegate.sample();