[refactor] Refactor VM#getInstancesMap() with Map#computeIfAbsent()
Test: atest MicrodroidTests Change-Id: I664cf4471573a38ab51e40736b1b6bae9614f6b2
This commit is contained in:
parent
2acbb01203
commit
b04942f337
|
@ -282,14 +282,7 @@ public class VirtualMachine implements AutoCloseable {
|
|||
@GuardedBy("sCreateLock")
|
||||
@NonNull
|
||||
private static Map<String, WeakReference<VirtualMachine>> getInstancesMap(Context context) {
|
||||
Map<String, WeakReference<VirtualMachine>> instancesMap;
|
||||
if (sInstances.containsKey(context)) {
|
||||
instancesMap = sInstances.get(context);
|
||||
} else {
|
||||
instancesMap = new HashMap<>();
|
||||
sInstances.put(context, instancesMap);
|
||||
}
|
||||
return instancesMap;
|
||||
return sInstances.computeIfAbsent(context, unused -> new HashMap<>());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
Loading…
Reference in New Issue