mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 14:12:11 +00:00
added caches for before/after fix determination
Change-Id: Iaf30f4e707b6d08a98996a050a42e41fd293aeef
This commit is contained in:
1 parent
73df2cb13d
commit
a6eeea64e2
1 file changed
+4
-3
+4
-3
@@ -709,7 +709,8 @@ public class CandidateFinderImpl implements CandidateFinder {
|
||||
Util.Pair<List<Candidate>, List<Candidate>> result = new Util.Pair<List<Candidate>, List<Candidate>>(
|
||||
new ArrayList<Candidate>(), new ArrayList<Candidate>());
|
||||
DynamicGPSFixTrack<Competitor, GPSFixMoving> track = race.getTrack(c);
|
||||
|
||||
final Map<TimePoint, GPSFixMoving> lastFixBeforeCache = new LimitedLinkedHashMap<>(10);
|
||||
final Map<TimePoint, GPSFixMoving> firstFixAfterCache = new LimitedLinkedHashMap<>(10);
|
||||
for (GPSFixMoving fix : fixes) {
|
||||
if (timeRangeForValidCandidates.getTimeRangeOrNull() != null && timeRangeForValidCandidates.getTimeRangeOrNull().includes(fix.getTimePoint())) {
|
||||
TimePoint t = fix.getTimePoint();
|
||||
@@ -720,8 +721,8 @@ public class CandidateFinderImpl implements CandidateFinder {
|
||||
try {
|
||||
fixIsValid = track.isValid(fix);
|
||||
if (fixIsValid) {
|
||||
fixBefore = track.getLastFixBefore(t);
|
||||
fixAfter = track.getFirstFixAfter(t);
|
||||
fixBefore = lastFixBeforeCache.computeIfAbsent(t, timePoint->track.getLastFixBefore(timePoint));
|
||||
fixAfter = firstFixAfterCache.computeIfAbsent(t, timePoint->track.getFirstFixAfter(timePoint));
|
||||
}
|
||||
} finally {
|
||||
track.unlockAfterRead();
|
||||
|
||||
Reference in new issue
Block a user