refine collection creations (#1974)

pull/2150/head^2
XenoAmess 3 years ago committed by GitHub
parent 9c24d9da03
commit ad260cadfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,7 @@ import java.util.Map.Entry;
public class StringUtils {
public static Map<String, String> removeDashKey(Map<String, String> map) {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<String, String>(map.size());
for (Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();

@ -257,16 +257,19 @@ public class ArthasBootstrap {
* https://github.com/alibaba/arthas/issues/986
* </pre>
*/
Map<String, String> copyMap = new HashMap<String, String>();
Map<String, Object> copyMap;
if (argsMap != null) {
copyMap.putAll(argsMap);
}
// 添加 arthas.home
if (!copyMap.containsKey(ARTHAS_HOME_PROPERTY)) {
copyMap = new HashMap<String, Object>(argsMap);
// 添加 arthas.home
if (!copyMap.containsKey(ARTHAS_HOME_PROPERTY)) {
copyMap.put(ARTHAS_HOME_PROPERTY, arthasHome());
}
} else {
copyMap = new HashMap<String, Object>(1);
copyMap.put(ARTHAS_HOME_PROPERTY, arthasHome());
}
MapPropertySource mapPropertySource = new MapPropertySource("args", (Map<String, Object>)(Object)copyMap);
MapPropertySource mapPropertySource = new MapPropertySource("args", copyMap);
arthasEnvironment.addFirst(mapPropertySource);
tryToLoadArthasProperties();

@ -42,7 +42,7 @@ public class DynamicCompilerException extends RuntimeException {
List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>();
if (diagnostics != null) {
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
Map<String, Object> message = new HashMap<String, Object>();
Map<String, Object> message = new HashMap<String, Object>(2);
message.put("line", diagnostic.getLineNumber());
message.put("message", diagnostic.getMessage(Locale.US));
messages.add(message);

@ -20,7 +20,7 @@ public class ArthasEndpoint {
@ReadOperation
public Map<String, Object> invoke() {
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>(4);
result.put("version", this.getClass().getPackage().getImplementationVersion());
result.put("properties", arthasProperties);

Loading…
Cancel
Save