Fix target line performance regression.

This commit is contained in:
Johannes Mockenhaupt 2018-08-06 17:34:07 +02:00
parent 409acd0721
commit 9af0bc2976
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -243,7 +243,7 @@ public class GraphData {
targetsScale.setMultiplier(1);
List<DataPoint> targetsSeriesArray = new ArrayList<>();
double lastTarget = 0;
double lastTarget = -1;
if (LoopPlugin.lastRun != null && LoopPlugin.lastRun.constraintsProcessed != null) {
APSResult apsResult = LoopPlugin.lastRun.constraintsProcessed;
@ -253,22 +253,22 @@ public class GraphData {
}
}
for (long time = fromTime; time < toTime; time += 60 * 1000L) {
for (long time = fromTime; time < toTime; time += 5 * 60 * 1000L) {
TempTarget tt = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(time);
double value;
if (tt == null) {
value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2;
} else {
value = tt.target();
value = Profile.fromMgdlToUnits(value, profile.getUnits());
value = Profile.fromMgdlToUnits(tt.target(), profile.getUnits());
}
if (lastTarget > 0 && lastTarget != value) {
targetsSeriesArray.add(new DataPoint(time, lastTarget));
if (lastTarget != value) {
if (lastTarget != -1)
targetsSeriesArray.add(new DataPoint(time, lastTarget));
targetsSeriesArray.add(new DataPoint(time, value));
}
lastTarget = value;
targetsSeriesArray.add(new DataPoint(time, value));
}
targetsSeriesArray.add(new DataPoint(toTime, lastTarget));
DataPoint[] targets = new DataPoint[targetsSeriesArray.size()];
targets = targetsSeriesArray.toArray(targets);