Fixes #2496: Removed potentially superfluous list copy.
This commit is contained in:
parent
87cebc3e3f
commit
83ac99da74
|
@ -25,6 +25,9 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Test if copy was actually necessary.
|
||||
*/
|
||||
public class NetworkList implements Collection<Grid>
|
||||
{
|
||||
|
||||
|
@ -69,14 +72,12 @@ public class NetworkList implements Collection<Grid>
|
|||
@Override
|
||||
public boolean add( final Grid e )
|
||||
{
|
||||
this.copy();
|
||||
return this.networks.add( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove( final Object o )
|
||||
{
|
||||
this.copy();
|
||||
return this.networks.remove( o );
|
||||
}
|
||||
|
||||
|
@ -89,21 +90,18 @@ public class NetworkList implements Collection<Grid>
|
|||
@Override
|
||||
public boolean addAll( final Collection<? extends Grid> c )
|
||||
{
|
||||
this.copy();
|
||||
return this.networks.addAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll( final Collection<?> c )
|
||||
{
|
||||
this.copy();
|
||||
return this.networks.removeAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll( final Collection<?> c )
|
||||
{
|
||||
this.copy();
|
||||
return this.networks.retainAll( c );
|
||||
}
|
||||
|
||||
|
@ -112,11 +110,4 @@ public class NetworkList implements Collection<Grid>
|
|||
{
|
||||
this.networks = new LinkedList<Grid>();
|
||||
}
|
||||
|
||||
private void copy()
|
||||
{
|
||||
final List<Grid> old = this.networks;
|
||||
this.networks = new LinkedList<Grid>();
|
||||
this.networks.addAll( old );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue