8287924: Avoid redundant HashMap.containsKey call in EnvHelp.mapToHashtable
Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
parent
d482d7f5b9
commit
900d967da5
@ -48,8 +48,6 @@ import javax.management.remote.JMXConnectorFactory;
|
|||||||
import javax.management.remote.JMXConnectorServerFactory;
|
import javax.management.remote.JMXConnectorServerFactory;
|
||||||
import com.sun.jmx.mbeanserver.GetPropertyAction;
|
import com.sun.jmx.mbeanserver.GetPropertyAction;
|
||||||
import com.sun.jmx.remote.security.NotificationAccessController;
|
import com.sun.jmx.remote.security.NotificationAccessController;
|
||||||
import javax.management.remote.JMXConnector;
|
|
||||||
import javax.management.remote.JMXConnectorServer;
|
|
||||||
|
|
||||||
public class EnvHelp {
|
public class EnvHelp {
|
||||||
|
|
||||||
@ -733,11 +731,11 @@ public class EnvHelp {
|
|||||||
* it removes all the 'null' values from the map.
|
* it removes all the 'null' values from the map.
|
||||||
*/
|
*/
|
||||||
public static <K, V> Hashtable<K, V> mapToHashtable(Map<K, V> map) {
|
public static <K, V> Hashtable<K, V> mapToHashtable(Map<K, V> map) {
|
||||||
HashMap<K, V> m = new HashMap<K, V>(map);
|
HashMap<K, V> m = new HashMap<>(map);
|
||||||
if (m.containsKey(null)) m.remove(null);
|
m.remove(null);
|
||||||
for (Iterator<?> i = m.values().iterator(); i.hasNext(); )
|
for (Iterator<?> i = m.values().iterator(); i.hasNext(); )
|
||||||
if (i.next() == null) i.remove();
|
if (i.next() == null) i.remove();
|
||||||
return new Hashtable<K, V>(m);
|
return new Hashtable<>(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user