mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Avoid allocations on Map::putIfAbsent usage
Map::computeIfAbsent only runs the passed constructors when it needs to
This commit is contained in:
@@ -106,8 +106,9 @@ public class TowerManager extends BasePlayerManager {
|
||||
|
||||
if (!hasNextLevel()) {
|
||||
// set up the next floor
|
||||
recordMap.putIfAbsent(getNextFloorId(), new TowerLevelRecord(getNextFloorId()));
|
||||
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(getNextFloorId(), 1));
|
||||
var nextFloorId = this.getNextFloorId();
|
||||
recordMap.computeIfAbsent(nextFloorId, TowerLevelRecord::new);
|
||||
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(nextFloorId, 1));
|
||||
}else {
|
||||
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(currentFloorId, getCurrentLevel()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user