mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-20 19:04:40 +01:00
Avoid allocations on Map::putIfAbsent usage
Map::computeIfAbsent only runs the passed constructors when it needs to
This commit is contained in:
@@ -42,7 +42,7 @@ public class WorldDataSystem extends BaseGameSystem {
|
||||
DataLoader.loadList("ChestReward.json", ChestReward.class)
|
||||
.forEach(reward ->
|
||||
reward.getObjNames().forEach(name ->
|
||||
chestInteractHandlerMap.putIfAbsent(name, new NormalChestInteractHandler(reward))));
|
||||
chestInteractHandlerMap.computeIfAbsent(name, x -> new NormalChestInteractHandler(reward))));
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Unable to load chest reward config.", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user