[MNG-6492] - Minor improvement on Array construction, conversion performance

This commit is contained in:
HoaPhan 2018-09-08 22:46:22 +10:00 committed by Karl Heinz Marbaise
parent e4b53d3f2c
commit ba74b96633
No known key found for this signature in database
GPG Key ID: BF1518E0160788A2
9 changed files with 11 additions and 22 deletions

View File

@ -313,12 +313,8 @@ public final class ModelUtils
public static List<Repository> mergeRepositoryLists( List<Repository> dominant, List<Repository> recessive )
{
List<Repository> repositories = new ArrayList<>();
for ( Repository repository : dominant )
{
repositories.add( repository );
}
List<Repository> repositories = new ArrayList<>( dominant );
for ( Repository repository : recessive )
{

View File

@ -139,7 +139,7 @@ public class DefaultClasspathTransformation
if ( exits != null && exits.size() > 0 )
{
MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[exits.size()] );
MetadataGraphEdge[] sortedExits = exits.toArray( new MetadataGraphEdge[0] );
Arrays.sort( sortedExits
,
new Comparator<MetadataGraphEdge>()

View File

@ -49,6 +49,7 @@ import org.eclipse.aether.resolution.VersionRangeRequest;
import org.eclipse.aether.resolution.VersionRangeResolutionException;
import org.eclipse.aether.resolution.VersionRangeResult;
/**
* A model resolver to assist building of projects. This resolver gives priority to those repositories that have been
* declared in the POM.
@ -91,9 +92,7 @@ public class ProjectModelResolver
this.resolver = resolver;
this.remoteRepositoryManager = remoteRepositoryManager;
this.pomRepositories = new ArrayList<>();
List<RemoteRepository> externalRepositories = new ArrayList<>();
externalRepositories.addAll( repositories );
this.externalRepositories = Collections.unmodifiableList( externalRepositories );
this.externalRepositories = Collections.unmodifiableList( new ArrayList<>( repositories ) );
this.repositories = new ArrayList<>();
this.repositories.addAll( externalRepositories );
this.repositoryMerging = repositoryMerging;

View File

@ -69,7 +69,7 @@ public class DefaultToolchainManagerPrivate
}
}
return toRet.toArray( new ToolchainPrivate[toRet.size()] );
return toRet.toArray( new ToolchainPrivate[0] );
}
@Override

View File

@ -50,10 +50,7 @@ public class MojoExecutorStub
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
throws LifecycleExecutionException
{
for ( MojoExecution mojoExecution : mojoExecutions )
{
executions.add( mojoExecution );
}
executions.addAll(mojoExecutions);
}

View File

@ -115,7 +115,7 @@ public class CleanArgument
}
else
{
cleanArgs = cleaned.toArray( new String[cleanedSz] );
cleanArgs = cleaned.toArray( new String[0] );
}
return cleanArgs;

View File

@ -384,7 +384,7 @@ public class MavenCli
}
}
mavenConfig = cliManager.parse( args.toArray( new String[args.size()] ) );
mavenConfig = cliManager.parse( args.toArray( new String[0] ) );
List<?> unrecongized = mavenConfig.getArgList();
if ( !unrecongized.isEmpty() )
{
@ -1196,7 +1196,7 @@ public class MavenCli
sb.append( String.format( "%s\n", configurationProcessor.getClass().getName() ) );
}
}
sb.append( String.format( "\n" ) );
sb.append( "\n" );
throw new Exception( sb.toString() );
}
}

View File

@ -263,9 +263,8 @@ public class StringSearchModelInterpolator
fields.add( new ObjectField( currentField ) );
}
}
}
this.fields = fields.toArray( new CacheField[fields.size()] );
this.fields = fields.toArray( new CacheField[0] );
}

View File

@ -89,9 +89,7 @@ class DefaultModelResolver
this.versionRangeResolver = versionRangeResolver;
this.remoteRepositoryManager = remoteRepositoryManager;
this.repositories = repositories;
List<RemoteRepository> externalRepositories = new ArrayList<>();
externalRepositories.addAll( repositories );
this.externalRepositories = Collections.unmodifiableList( externalRepositories );
this.externalRepositories = Collections.unmodifiableList( new ArrayList<>( repositories ) );
this.repositoryIds = new HashSet<>();
}