From cf8653567c824d2e700dcf2061261868d93870c7 Mon Sep 17 00:00:00 2001 From: NoName11234 <47484268+NoName11234@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:17:12 +0200 Subject: [PATCH] changed arraylist to concurrent set and removed snychronized --- .../typeinference/unify/model/PlaceholderType.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 07d8572..facaed1 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -1,13 +1,10 @@ package de.dhbwstuttgart.typeinference.unify.model; -import java.io.File; -import java.io.FileWriter; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; import java.util.Random; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import de.dhbwstuttgart.typeinference.unify.distributeVariance; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; @@ -23,7 +20,7 @@ public final class PlaceholderType extends UnifyType{ * Static list containing the names of all existing placeholders. * Used for generating fresh placeholders. */ - public static final ArrayList EXISTING_PLACEHOLDERS = new ArrayList(); + public static final Set EXISTING_PLACEHOLDERS = ConcurrentHashMap.newKeySet(); /** * Prefix of auto-generated placeholder names. @@ -96,7 +93,7 @@ public final class PlaceholderType extends UnifyType{ * A user could later instantiate a type using the same name that is equivalent to this type. * @return A fresh placeholder type. */ - public synchronized static PlaceholderType freshPlaceholder() { + public static PlaceholderType freshPlaceholder() { String name = nextName + (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z' // Add random chars while the name is in use. while(EXISTING_PLACEHOLDERS.contains(name)) {