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