From 9b907b336a4f618e7ab67d1b2ffcef5613f7e062 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Thu, 17 Dec 2015 17:32:51 -0800 Subject: [PATCH] results should store const ObjectSchema --- src/object-store/list.hpp | 2 +- src/object-store/object_accessor.hpp | 2 +- src/object-store/results.cpp | 9 +++++++++ src/object-store/results.hpp | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/object-store/list.hpp b/src/object-store/list.hpp index 934c56ce..fdde4c62 100644 --- a/src/object-store/list.hpp +++ b/src/object-store/list.hpp @@ -27,7 +27,7 @@ namespace realm { public: List(SharedRealm &r, const ObjectSchema &s, LinkViewRef l) : m_realm(r), object_schema(s), m_link_view(l) {} - const ObjectSchema object_schema; + const ObjectSchema &object_schema; SharedRealm realm() { return m_realm; } size_t size(); diff --git a/src/object-store/object_accessor.hpp b/src/object-store/object_accessor.hpp index 5d290d43..ae1025f0 100644 --- a/src/object-store/object_accessor.hpp +++ b/src/object-store/object_accessor.hpp @@ -27,7 +27,7 @@ namespace realm { template static inline Object create(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType value, bool try_update); - const ObjectSchema object_schema; + const ObjectSchema &object_schema; SharedRealm realm() { return m_realm; } Row row() { return m_row; } diff --git a/src/object-store/results.cpp b/src/object-store/results.cpp index 2f466476..e879c6b7 100644 --- a/src/object-store/results.cpp +++ b/src/object-store/results.cpp @@ -38,6 +38,15 @@ Results::Results(SharedRealm r, const ObjectSchema &o, Table& table) { } +Results& Results::operator=(Results const& r) +{ + m_realm = r.m_realm; + const_cast(object_schema) = r.object_schema; + m_query = r.get_query(); + m_sort = r.get_sort(); + return *this; +} + void Results::validate_read() const { if (m_realm) diff --git a/src/object-store/results.hpp b/src/object-store/results.hpp index 53ee6815..115ca636 100644 --- a/src/object-store/results.hpp +++ b/src/object-store/results.hpp @@ -38,14 +38,14 @@ public: // Results is copyable and moveable Results(Results const&) = default; Results(Results&&) = default; - Results& operator=(Results const&) = default; Results& operator=(Results&&) = default; + Results& operator=(Results const&); // Get the Realm SharedRealm get_realm() const { return m_realm; } // Object schema describing the vendored object type - ObjectSchema object_schema; + const ObjectSchema &object_schema; // Get a query which will match the same rows as is contained in this Results // Returned query will not be valid if the current mode is Empty