mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-29 15:56:09 +00:00
Merge pull request #66 from realm/tg/unregister-realm
Use erase-remove_if in RealmCoordinator::unregister_realm()
This commit is contained in:
commit
399b6d88dc
@ -152,17 +152,9 @@ RealmCoordinator::~RealmCoordinator()
|
|||||||
void RealmCoordinator::unregister_realm(Realm* realm)
|
void RealmCoordinator::unregister_realm(Realm* realm)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_realm_mutex);
|
std::lock_guard<std::mutex> lock(m_realm_mutex);
|
||||||
for (size_t i = 0; i < m_weak_realm_notifiers.size(); ++i) {
|
auto new_end = remove_if(begin(m_weak_realm_notifiers), end(m_weak_realm_notifiers),
|
||||||
auto& weak_realm_notifier = m_weak_realm_notifiers[i];
|
[=](auto& notifier) { return notifier.expired() || notifier.is_for_realm(realm); });
|
||||||
if (!weak_realm_notifier.expired() && !weak_realm_notifier.is_for_realm(realm)) {
|
m_weak_realm_notifiers.erase(new_end, end(m_weak_realm_notifiers));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i + 1 < m_weak_realm_notifiers.size()) {
|
|
||||||
weak_realm_notifier = std::move(m_weak_realm_notifiers.back());
|
|
||||||
}
|
|
||||||
m_weak_realm_notifiers.pop_back();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RealmCoordinator::clear_cache()
|
void RealmCoordinator::clear_cache()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user