Small perf: one less unneeded allocation#3280
Conversation
…st get this._tiles which is a set, and the method turns it into a ReadOnlySet already
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/core/game/PlayerImpl.ts`:
- Around line 334-336: Revert the change to tiles(): it must return a defensive
snapshot rather than the live Set to avoid iterator invalidation; update
PlayerImpl.tiles() to return a new Set constructed from this._tiles (e.g., new
Set(this._tiles.values())) so callers like SpawnExecution
(player.tiles().forEach(...)) and tests that iterate other.tiles() won’t be
iterating the internal _tiles while GameImpl.relinquish() or GameImpl.conquer()
call _tiles.delete(); also audit borderTiles() for similar live-alias risks and
make it return a snapshot if it currently returns the internal Set.
Description:
(retracted)
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
tryout33