From aca2e12116e7cdb944d9386b033b815ffbd69815 Mon Sep 17 00:00:00 2001 From: James Stone Date: Tue, 2 Jul 2019 17:42:13 +0200 Subject: [PATCH] Fix poor performance of an IncludeDescriptor (#3311) --- CHANGELOG.md | 4 ++-- src/realm/views.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d708d03ca6f..3405ef7133f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ * Add a Swift Package Manager packgae ([#3308](https://github.com/realm/realm-core/pull/3308)). ### Fixed -* ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) -* None. +* Constructing an `IncludeDescriptor` made unnecessary table comparisons. This resulted in poor performance for subscriptions + using the `includeLinkingObjects` functionality. ([#3311](https://github.com/realm/realm-core/issues/3311), since v5.18.0) ### Breaking changes * None. diff --git a/src/realm/views.cpp b/src/realm/views.cpp index 435c1f04440..e110a1c690b 100644 --- a/src/realm/views.cpp +++ b/src/realm/views.cpp @@ -342,12 +342,12 @@ IncludeDescriptor::IncludeDescriptor(const Table& table, const std::vectorget_link_target(link.column_ndx)); + REALM_ASSERT_DEBUG(cur_table->get_name() == link.from->get_link_target(link.column_ndx)->get_name()); auto& col = tf::get_column(*link.from, link.column_ndx); columns.push_back(&col); backlink_source.push_back(link.from); if (auto link_col = dynamic_cast(&col)) { // LinkColumn and ListColumn - if (link_col->get_target_table() != *cur_table) { + if (link_col->get_target_table().get_name() != cur_table->get_name()) { // the link does not point to the last table in the chain throw InvalidPathError(util::format("Invalid INCLUDE path at [%1, %2]: this link does not " "connect to the previous table ('%3').",