Skip to content

Commit a365369

Browse files
committed
Remove SyncUser::operator==()
It had incorrect semantics (users from different Apps which happened to have the same id would compare equal), and simply isn't neccesary as there should only ever be a single SyncUser instance per user and so pointer equality suffices.
1 parent 37177fb commit a365369

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
### Breaking changes
1818
* SyncUser::provider_type() and realm_user_get_auth_provider() have been removed. Users don't have provider types; identities do.
1919
* SyncUser no longer has a `local_identity()`. `identity()` has been guaranteed to be unique per App ever since v10.
20+
* SyncUser no longer overrides operator==. Pointer equality should be used to compare sync users.
2021

2122
### Compatibility
2223
* Fileformat: Generates files with format v23. Reads and automatically upgrade from fileformat v5.

src/realm/object-store/c_api/types.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ struct realm_user : realm::c_api::WrapC, std::shared_ptr<realm::SyncUser> {
661661
bool equals(const WrapC& other) const noexcept final
662662
{
663663
if (auto ptr = dynamic_cast<const realm_user*>(&other)) {
664-
return *get() == *(ptr->get());
664+
return get() == ptr->get();
665665
}
666666
return false;
667667
}

src/realm/object-store/impl/realm_coordinator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void RealmCoordinator::set_config(const Realm::Config& config)
183183
if (config.sync_config) {
184184
auto old_user = m_config.sync_config->user;
185185
auto new_user = config.sync_config->user;
186-
if (old_user && new_user && *old_user != *new_user) {
186+
if (old_user != new_user) {
187187
throw LogicError(
188188
ErrorCodes::MismatchedConfig,
189189
util::format("Realm at path '%1' already opened with different sync user.", config.path));

src/realm/object-store/sync/sync_user.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,6 @@ class SyncUser : public std::enable_shared_from_this<SyncUser>, public Subscriba
284284
m_seconds_to_adjust_time_for_testing.store(seconds);
285285
}
286286

287-
/// Check the SyncUsers passed as argument have the same remote identity id.
288-
friend bool operator==(const SyncUser& lhs, const SyncUser& rhs)
289-
{
290-
return lhs.identity() == rhs.identity();
291-
}
292-
293-
friend bool operator!=(const SyncUser& lhs, const SyncUser& rhs)
294-
{
295-
return !(lhs == rhs);
296-
}
297-
298287
protected:
299288
friend class SyncManager;
300289
void detach_from_sync_manager() REQUIRES(!m_mutex);

0 commit comments

Comments
 (0)