From 1e36beb263891bccda0d2e99fcdb2bc139545dac Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 4 Jan 2016 16:21:28 -0800 Subject: [PATCH] store ObjectSchema as a pointer rather than a reference --- object_accessor.hpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/object_accessor.hpp b/object_accessor.hpp index eed939e1..dc50240d 100644 --- a/object_accessor.hpp +++ b/object_accessor.hpp @@ -14,7 +14,7 @@ namespace realm { class Object { public: - Object(SharedRealm r, const ObjectSchema &s, Row o) : m_realm(r), object_schema(s), m_row(o) {} + Object(SharedRealm r, const ObjectSchema &s, Row o) : m_realm(r), m_object_schema(&s), m_row(o) {} // property getter/setter template @@ -27,12 +27,13 @@ namespace realm { template static inline Object create(ContextType ctx, SharedRealm realm, const ObjectSchema &object_schema, ValueType value, bool try_update); - const ObjectSchema &object_schema; SharedRealm realm() { return m_realm; } + const ObjectSchema &object_schema() { return *m_object_schema; } Row row() { return m_row; } private: SharedRealm m_realm; + const ObjectSchema *m_object_schema; Row m_row; template @@ -119,10 +120,10 @@ namespace realm { template inline void Object::set_property_value(ContextType ctx, std::string prop_name, ValueType value, bool try_update) { - const Property *prop = object_schema.property_for_name(prop_name); + const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { - throw InvalidPropertyException(object_schema.name, prop_name, - "Setting invalid property '" + prop_name + "' on object '" + object_schema.name + "'."); + throw InvalidPropertyException(m_object_schema->name, prop_name, + "Setting invalid property '" + prop_name + "' on object '" + m_object_schema->name + "'."); } set_property_value_impl(ctx, *prop, value, try_update); }; @@ -130,10 +131,10 @@ namespace realm { template inline ValueType Object::get_property_value(ContextType ctx, std::string prop_name) { - const Property *prop = object_schema.property_for_name(prop_name); + const Property *prop = m_object_schema->property_for_name(prop_name); if (!prop) { - throw InvalidPropertyException(object_schema.name, prop_name, - "Getting invalid property '" + prop_name + "' on object '" + object_schema.name + "'."); + throw InvalidPropertyException(m_object_schema->name, prop_name, + "Getting invalid property '" + prop_name + "' on object '" + m_object_schema->name + "'."); } return get_property_value_impl(ctx, *prop); };