olamy commented on a change in pull request #358:
URL: https://github.com/apache/maven/pull/358#discussion_r433590126



##########
File path: maven-core/src/main/java/org/apache/maven/project/MavenProject.java
##########
@@ -921,12 +926,20 @@ public void setInjectedProfileIds( String source, 
List<String> injectedProfileId
      * coordinates.
      *
      * @param artifact the artifact to add or replace.
-     * @throws DuplicateArtifactAttachmentException
+     * @deprecated Please use {@link MavenProjectHelper}
+     * @throws DuplicateArtifactAttachmentException not used anymore but leave 
it for backward compatibility
      */
     public void addAttachedArtifact( Artifact artifact )
         throws DuplicateArtifactAttachmentException
     {
-        getAttachedArtifacts().add( artifact );
+        // if already there we remove it and add again
+        int index = attachedArtifacts.indexOf( artifact );

Review comment:
       we are talking about list of 6/7 elements which are not accessed that 
much especially for add.
   My first idea was to use Set but this will make the `getAttachedArtifacts` 
method to recreate a List based on the  Set and makes this new List 
unmodifiable as well.
   I can make some jmh to compare but not sure it really worth it...
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to