From 18a6c5ab42aae9e74a13ae901081111099dc9bb8 Mon Sep 17 00:00:00 2001 From: CPunch Date: Tue, 28 Nov 2023 21:21:24 -0600 Subject: [PATCH] oh, this is safe actually https://stackoverflow.com/a/23230406 --- internal/entity/chunk.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/internal/entity/chunk.go b/internal/entity/chunk.go index f83a605..fdd2cd7 100644 --- a/internal/entity/chunk.go +++ b/internal/entity/chunk.go @@ -40,15 +40,7 @@ func (c *Chunk) SendPacket(typeID uint32, pkt ...interface{}) { // calls f for each entity in this chunk, if f returns true, stop iterating // f can safely add/remove entities from the chunk func (c *Chunk) ForEachEntity(f func(entity Entity) bool) { - // copy entities to avoid locking for the entire iteration - entities := make(map[Entity]struct{}) - c.lock.Lock() for entity := range c.entities { - entities[entity] = struct{}{} - } - c.lock.Unlock() - - for entity := range entities { if f(entity) { break }