desruisseaux commented on PR #2092: URL: https://github.com/apache/maven/pull/2092#issuecomment-2642425850
It brings a related question. The following code also has a O(N²) performance cost if a large number _N_ of sources are added through this method: ```java private List<SourceRoot> sources = new CopyOnWriteArrayList<>(); public void addSourceRoot(SourceRoot source) { if (!sources.contains(source)) { sources.add(source); } } ``` We could reduce the cost to O(N) by using `LinkedHashSet` instead of a list. However, `CopyOnWriteArrayList` is thread-safe while `LinkedHashSet` is not. Do we really need thread-safety for that particular field while everything else in `MavenProject` is not thread-safe? I agree that we may want thread-safety later, but maybe it would need to a more general strategy (e.g. with immutable records)? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org