From d00a18172fc69ec0f48383f530765c05c304ab84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= Date: Sun, 18 Feb 2024 18:42:38 +0100 Subject: [PATCH] Simplify repeated logic --- src/query/procedure/mg_procedure_impl.cpp | 30 ++++++----------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index 087d4e016..a7d099123 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -3423,28 +3423,14 @@ void WrapTextSearch(std::vector vertex_ids, std::string mgp_error mgp_graph_search_text_index(mgp_graph *graph, const char *index_name, const char *search_query, mgp_memory *memory, mgp_map **result) { return WrapExceptions([graph, memory, index_name, search_query, result]() { - std::visit(memgraph::utils::Overloaded{[&](memgraph::query::DbAccessor *impl) { - std::vector search_results; - std::string error_msg; - try { - search_results = impl->TextIndexSearch(index_name, search_query); - } catch (memgraph::query::QueryException &e) { - error_msg = e.what(); - } - WrapTextSearch(search_results, error_msg, graph, memory, result); - }, - [&](memgraph::query::SubgraphDbAccessor *impl) { - std::vector search_results; - std::string error_msg; - try { - search_results = - impl->GetAccessor()->TextIndexSearch(index_name, search_query); - } catch (memgraph::query::QueryException &e) { - error_msg = e.what(); - } - WrapTextSearch(search_results, error_msg, graph, memory, result); - }}, - graph->impl); + std::vector search_results; + std::string error_msg; + try { + search_results = graph->getImpl()->TextIndexSearch(index_name, search_query); + } catch (memgraph::query::QueryException &e) { + error_msg = e.what(); + } + WrapTextSearch(search_results, error_msg, graph, memory, result); }); }