summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfredzio <chardon.frederic@gmail.com>2021-05-05 20:28:46 +0200
committerfredzio <chardon.frederic@gmail.com>2021-05-05 20:28:46 +0200
commit65d860818365b5fc58a0ea37c5c01a5a330c7c36 (patch)
tree6af3f17d0c38a3cce72390f11e6286447bd43894
parent00de540a31f4bf64c0302b9b2b77c1666dc28612 (diff)
Simplify the codedeadcode
-rw-r--r--apps/openmw/mwworld/store.cpp24
1 files changed, 5 insertions, 19 deletions
diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp
index 94795b8417..42053197bc 100644
--- a/apps/openmw/mwworld/store.cpp
+++ b/apps/openmw/mwworld/store.cpp
@@ -12,24 +12,6 @@
namespace
{
- template<typename T>
- class GetRecords
- {
- const std::string mFind;
- std::vector<const T*> *mRecords;
-
- public:
- GetRecords(const std::string &str, std::vector<const T*> *records)
- : mFind(Misc::StringUtils::lowerCase(str)), mRecords(records)
- { }
-
- void operator()(const T *item)
- {
- if(Misc::StringUtils::ciCompareLen(mFind, item->mId, mFind.size()) == 0)
- mRecords->push_back(item);
- }
- };
-
struct Compare
{
bool operator()(const ESM::Land *x, const ESM::Land *y) {
@@ -169,7 +151,11 @@ namespace MWWorld
const T *Store<T>::searchRandom(const std::string &id) const
{
std::vector<const T*> results;
- std::for_each(mShared.begin(), mShared.end(), GetRecords<T>(id, &results));
+ std::copy_if(mShared.begin(), mShared.end(), results.begin(),
+ [&id](const T* item)
+ {
+ return Misc::StringUtils::ciCompareLen(id, item->mId, id.size()) == 0;
+ });
if(!results.empty())
return results[Misc::Rng::rollDice(results.size())];
return nullptr;