Avoid unnecessary empty array creation

This commit is contained in:
Ville Skyttä 2016-04-10 19:34:22 +03:00 committed by Clebert Suconic
parent bb739be92d
commit 11acf2180f
6 changed files with 11 additions and 7 deletions

View File

@ -777,7 +777,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
destinations.add(control.getAddress());
}
}
return destinations.toArray(new String[0]);
return destinations.toArray(new String[destinations.size()]);
}
@Override

View File

@ -143,7 +143,7 @@ public class OsgiBroker {
protocols.add(protoName);
}
}
return protocols.toArray(new String[]{});
return protocols.toArray(new String[protocols.size()]);
}
@Deactivate

View File

@ -23,6 +23,8 @@ import org.apache.activemq.artemis.core.config.BridgeConfiguration;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.Bridge;
import java.util.List;
public class BridgeControlImpl extends AbstractControl implements BridgeControl {
// Constants -----------------------------------------------------
@ -51,7 +53,8 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
public String[] getStaticConnectors() throws Exception {
clearIO();
try {
return configuration.getStaticConnectors().toArray(new String[0]);
List<String> staticConnectors = configuration.getStaticConnectors();
return staticConnectors.toArray(new String[staticConnectors.size()]);
}
finally {
blockOnIO();

View File

@ -125,11 +125,12 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
public String[] getStaticConnectors() {
clearIO();
try {
if (configuration.getStaticConnectors() == null) {
List<String> staticConnectors = configuration.getStaticConnectors();
if (staticConnectors == null) {
return null;
}
else {
return configuration.getStaticConnectors().toArray(new String[0]);
return staticConnectors.toArray(new String[staticConnectors.size()]);
}
}
finally {

View File

@ -48,7 +48,7 @@ public class MBeanInfoHelper {
}
}
return operations.toArray(new MBeanOperationInfo[0]);
return operations.toArray(new MBeanOperationInfo[operations.size()]);
}
// Package protected ---------------------------------------------

View File

@ -358,7 +358,7 @@ public class NettyAcceptor extends AbstractAcceptor {
set.add(s);
}
warningPrinted.set(true);
engine.setEnabledProtocols(set.toArray(new String[0]));
engine.setEnabledProtocols(set.toArray(new String[set.size()]));
SslHandler handler = new SslHandler(engine);