diff --git a/object_schema.cpp b/object_schema.cpp index adf5bc94..e4cbc195 100644 --- a/object_schema.cpp +++ b/object_schema.cpp @@ -22,7 +22,7 @@ using namespace realm; using namespace std; -ObjectSchema::ObjectSchema(realm::Group *group, std::string name) : name(name) { +ObjectSchema::ObjectSchema(realm::Group *group, const std::string &name) : name(name) { TableRef table = ObjectStore::table_for_object_type(group, name); size_t count = table->get_column_count(); for (size_t col = 0; col < count; col++) { @@ -55,7 +55,7 @@ ObjectSchema::ObjectSchema(realm::Group *group, std::string name) : name(name) { } } -Property *ObjectSchema::property_for_name(std::string name) { +Property *ObjectSchema::property_for_name(const std::string &name) { for (auto& prop:properties) { if (prop.name == name) { return ∝ diff --git a/object_schema.hpp b/object_schema.hpp index 23918117..54ee2a14 100644 --- a/object_schema.hpp +++ b/object_schema.hpp @@ -29,13 +29,13 @@ namespace realm { class ObjectSchema { public: ObjectSchema() {} - ObjectSchema(Group *group, std::string name); + ObjectSchema(Group *group, const std::string &name); std::string name; std::vector properties; std::string primary_key; - Property *property_for_name(std::string name); + Property *property_for_name(const std::string &name); Property *primary_key_property() { return property_for_name(primary_key); } diff --git a/object_store.cpp b/object_store.cpp index fd20858a..b8021c33 100644 --- a/object_store.cpp +++ b/object_store.cpp @@ -109,14 +109,14 @@ void ObjectStore::set_primary_key_for_object(realm::Group *group, StringData obj } } -string ObjectStore::object_type_for_table_name(string table_name) { +string ObjectStore::object_type_for_table_name(const string &table_name) { if (table_name.compare(0, 6, c_object_table_name_prefix) == 0) { return table_name.substr(6, table_name.length()-6); } return string(); } -string ObjectStore::table_name_for_object_type(string object_type) { +string ObjectStore::table_name_for_object_type(const string &object_type) { return c_object_table_name_prefix + object_type; } @@ -124,7 +124,7 @@ realm::TableRef ObjectStore::table_for_object_type(realm::Group *group, StringDa return group->get_table(table_name_for_object_type(object_type)); } -realm::TableRef ObjectStore::table_for_object_type_create_if_needed(realm::Group *group, StringData object_type, bool &created) { +realm::TableRef ObjectStore::table_for_object_type_create_if_needed(realm::Group *group, const StringData &object_type, bool &created) { return group->get_or_add_table(table_name_for_object_type(object_type), &created); } diff --git a/object_store.hpp b/object_store.hpp index f342d4a9..f067c605 100644 --- a/object_store.hpp +++ b/object_store.hpp @@ -83,9 +83,9 @@ namespace realm { // must be in write transaction to set static void set_primary_key_for_object(Group *group, StringData object_type, StringData primary_key); - static TableRef table_for_object_type_create_if_needed(Group *group, StringData object_type, bool &created); - static std::string table_name_for_object_type(std::string class_name); - static std::string object_type_for_table_name(std::string table_name); + static TableRef table_for_object_type_create_if_needed(Group *group, const StringData &object_type, bool &created); + static std::string table_name_for_object_type(const std::string &class_name); + static std::string object_type_for_table_name(const std::string &table_name); // returns if any indexes were changed static bool update_indexes(Group *group, Schema &schema);