mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 14:30:10 +00:00
use HashSet instead of ArrayList in getStandaloneBoats() for performance
Change-Id: Ie6648a8f81ea9534bfe411cd2902ed1c082ce5ec
This commit is contained in:
1 parent
a66ffac4b3
commit
e750f974be
2 files changed
+3
-6
No files matched your search
+2
-3
@@ -601,9 +601,9 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
public Iterable<Boat> getStandaloneBoats() {
|
||||
LockUtil.lockForRead(lock);
|
||||
try {
|
||||
List<Boat> boats = new ArrayList<>(boatCache.values());
|
||||
Set<Boat> boats = new HashSet<>(boatCache.values());
|
||||
Set<Boat> boatsEmbeddedInCompetitors = new HashSet<>();
|
||||
for (Competitor competitor: competitorCache.values()) {
|
||||
for (Competitor competitor : competitorCache.values()) {
|
||||
if (isValidCompetitorWithBoat(competitor)) {
|
||||
boatsEmbeddedInCompetitors.add(((CompetitorWithBoat) competitor).getBoat());
|
||||
}
|
||||
@@ -613,7 +613,6 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
} finally {
|
||||
LockUtil.unlockAfterRead(lock);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void removeBoat(Boat boat) {
|
||||
|
||||
+1
-3
@@ -82,14 +82,12 @@ public class PersistentCompetitorStore extends TransientCompetitorStoreImpl impl
|
||||
if (allLegacyCompetitorsWithBoat != null) {
|
||||
List<Competitor> newCompetitors = new ArrayList<>();
|
||||
List<Boat> newBoats = new ArrayList<>();
|
||||
|
||||
for (CompetitorWithBoat competitorWithBoat: allLegacyCompetitorsWithBoat) {
|
||||
for (CompetitorWithBoat competitorWithBoat : allLegacyCompetitorsWithBoat) {
|
||||
Boat containedBoat = competitorWithBoat.getBoat();
|
||||
// Create a new random uuid for the boats to make sure the competitor uuid is not used
|
||||
UUID boatUUID = UUID.randomUUID();
|
||||
DynamicBoat newBoat = new BoatImpl(boatUUID, null /* the old boat names were nonsense names */, containedBoat.getBoatClass(), containedBoat.getSailID());
|
||||
newBoats.add(newBoat);
|
||||
|
||||
CompetitorWithBoat newCompetitorWithBoat = new CompetitorWithBoatImpl((Competitor) competitorWithBoat, newBoat);
|
||||
newCompetitors.add(newCompetitorWithBoat);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user