From 7772f5111b4d4ced3a7311010fdfbe0b3704b5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Mocquillon?= Date: Mon, 26 Jul 2021 18:30:06 +0200 Subject: [PATCH] std::set version --- apps/openmw/mwworld/store.cpp | 11 +++++------ apps/openmw/mwworld/store.hpp | 30 ++++++++++++------------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index d2c4725117..b6e8aafdc9 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -422,9 +422,8 @@ namespace MWWorld const ESM::Land *Store::search(int x, int y) const { std::pair comp(x,y); - if (auto it = mStatic.find(comp); it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) { - return it->get(); - } + if (auto it = mStatic.find(comp); it != mStatic.end() && it->mX == x && it->mY == y) + return &*it; return nullptr; } const ESM::Land *Store::find(int x, int y) const @@ -439,13 +438,13 @@ namespace MWWorld } RecordId Store::load(ESM::ESMReader &esm) { - auto ptr = std::make_unique(); + ESM::Land land; bool isDeleted = false; - ptr->load(esm, isDeleted); + land.load(esm, isDeleted); // Same area defined in multiple plugins? -> last plugin wins - mStatic.insert(std::move(ptr)); + mStatic.insert(std::move(land)); return RecordId("", isDeleted); } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index d65422516a..88edb71ddf 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "recordcmp.hpp" @@ -239,30 +239,24 @@ namespace MWWorld { using is_transparent = void; - bool operator()(const std::unique_ptr& x, const std::unique_ptr& y) const { - if (x->mX == y->mX) { - return x->mY < y->mY; - } - return x->mX < y->mX; + bool operator()(const ESM::Land& x, const ESM::Land& y) const + { + return std::tie(x.mX, x.mY) < std::tie(y.mX, y.mY); } - bool operator()(const std::unique_ptr& x, const std::pair& y) const { - if (x->mX == y.first) { - return x->mY < y.second; - } - return x->mX < y.first; + bool operator()(const ESM::Land& x, const std::pair& y) const + { + return std::tie(x.mX, x.mY) < std::tie(y.first, y.second); } - bool operator()(const std::pair& x, const std::unique_ptr& y) const { - if (x.first == y->mX) { - return x.second < y->mY; - } - return x.first < y->mX; + bool operator()(const std::pair& x, const ESM::Land& y) const + { + return std::tie(x.first, x.second) < std::tie(y.mX, y.mY); } }; - using Statics = boost::container::flat_set, SpatialComparator>; + using Statics = std::set; Statics mStatic; public: - typedef SharedIterator iterator; + typedef typename Statics::iterator iterator; virtual ~Store();