o Tuned code

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@833044 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-11-05 13:15:54 +00:00
parent c980cfb28d
commit ed43cef785
1 changed files with 17 additions and 8 deletions

View File

@ -52,10 +52,10 @@ public class DefaultModelNormalizer
Build build = model.getBuild();
if ( build != null )
{
List<Plugin> original = build.getPlugins();
Map<Object, Plugin> normalized = new LinkedHashMap<Object, Plugin>();
List<Plugin> plugins = build.getPlugins();
Map<Object, Plugin> normalized = new LinkedHashMap<Object, Plugin>( plugins.size() * 2 );
for ( Plugin plugin : original )
for ( Plugin plugin : plugins )
{
Object key = plugin.getKey();
Plugin first = normalized.get( key );
@ -66,7 +66,10 @@ public class DefaultModelNormalizer
normalized.put( key, plugin );
}
build.setPlugins( new ArrayList<Plugin>( normalized.values() ) );
if ( plugins.size() != normalized.size() )
{
build.setPlugins( new ArrayList<Plugin>( normalized.values() ) );
}
}
/*
@ -76,12 +79,18 @@ public class DefaultModelNormalizer
* the way 2.x works. When we're in strict mode, the removal of duplicates just saves other merging steps from
* aftereffects and bogus error messages.
*/
Map<String, Dependency> dependencies = new LinkedHashMap<String, Dependency>();
for ( Dependency dependency : model.getDependencies() )
List<Dependency> dependencies = model.getDependencies();
Map<String, Dependency> normalized = new LinkedHashMap<String, Dependency>( dependencies.size() * 2 );
for ( Dependency dependency : dependencies )
{
dependencies.put( dependency.getManagementKey(), dependency );
normalized.put( dependency.getManagementKey(), dependency );
}
if ( dependencies.size() != normalized.size() )
{
model.setDependencies( new ArrayList<Dependency>( normalized.values() ) );
}
model.setDependencies( new ArrayList<Dependency>( dependencies.values() ) );
}
private static class DuplicateMerger