mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
refine collection creations (#1974)
This commit is contained in:
@@ -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();
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user