diff --git a/src/openrct2/entity/Litter.cpp b/src/openrct2/entity/Litter.cpp index 34d3f4b7d3..12177c7516 100644 --- a/src/openrct2/entity/Litter.cpp +++ b/src/openrct2/entity/Litter.cpp @@ -13,6 +13,8 @@ #include "EntityList.h" #include "EntityRegistry.h" +#include + using namespace OpenRCT2; template<> @@ -101,7 +103,9 @@ void Litter::Create(const CoordsXYZD& litterPos, Type type) */ void Litter::RemoveAt(const CoordsXYZ& litterPos) { - std::vector removals; + // There can be a lot of litter entities on the same tile, avoid heap allocations + // by having the first 512 stored in a small_vector which is on the stack. + sfl::small_vector removals; for (auto litter : EntityTileList(litterPos)) { if (abs(litter->z - litterPos.z) <= 16)