From 96c9743e65ac95706be3f49da3254d8db4c3afba Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 22 Feb 2024 19:41:55 +0100 Subject: src/{world,dijkstra}: get rid of extra indirection in neighbor list --- src/world.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index 759b9060..a28db7d3 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -188,14 +188,11 @@ void world::throw_on_wrong_object_type(object_id id, object_type actual, object_ fm_throw("object '{}' has wrong object type '{}', should be '{}'"_cf, id, (size_t)actual, (size_t)expected); } -auto world::neighbors(chunk_coords_ coord) -> std::array +auto world::neighbors(chunk_coords_ coord) -> std::array { - std::array ret; - for (auto i = 0uz; const auto& x : neighbor_offsets) - { - auto ch = coord + x; - ret[i++] = { at(ch), ch }; - } + std::array ret; + for (auto i = 0u; i < 8; i++) + ret[i] = at(coord + neighbor_offsets[i]); return ret; } -- cgit v1.2.3