Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
7d523efd
Commit
7d523efd
authored
Aug 19, 2022
by
AnimeGitB
Browse files
Avoid allocations on Map::putIfAbsent usage
Map::computeIfAbsent only runs the passed constructors when it needs to
parent
0cb75aeb
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/tower/TowerManager.java
View file @
7d523efd
...
...
@@ -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
()));
}
...
...
src/main/java/emu/grasscutter/game/world/WorldDataSystem.java
View file @
7d523efd
...
...
@@ -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
.
com
put
e
IfAbsent
(
name
,
x
->
new
NormalChestInteractHandler
(
reward
))));
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Unable to load chest reward config."
,
e
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment