Skip to content

Commit

Permalink
Pre-calculate intervalInSecond in LeapArray to reduce redundant calcu…
Browse files Browse the repository at this point in the history
…lation (#1700)
  • Loading branch information
mikawudi committed Aug 27, 2020
1 parent b91305a commit d5eb5f4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public abstract class LeapArray<T> {
protected int windowLengthInMs;
protected int sampleCount;
protected int intervalInMs;
private double intervalInSecond;

protected final AtomicReferenceArray<WindowWrap<T>> array;

Expand All @@ -64,6 +65,7 @@ public LeapArray(int sampleCount, int intervalInMs) {

this.windowLengthInMs = intervalInMs / sampleCount;
this.intervalInMs = intervalInMs;
this.intervalInSecond = intervalInMs / 1000.0;
this.sampleCount = sampleCount;

this.array = new AtomicReferenceArray<>(sampleCount);
Expand Down Expand Up @@ -393,7 +395,7 @@ public int getIntervalInMs() {
* @return interval in second
*/
public double getIntervalInSecond() {
return intervalInMs / 1000.0;
return intervalInSecond;
}

public void debug(long time) {
Expand Down

0 comments on commit d5eb5f4

Please sign in to comment.