From c0cb53e156c649ddeba00718dc912a2f740a35f6 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 22 Nov 2022 14:20:22 +0100 Subject: [PATCH] Replace if by switch --- src/storage/v3/request_helper.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/storage/v3/request_helper.hpp b/src/storage/v3/request_helper.hpp index 2ac8e05ae..2f469ae5b 100644 --- a/src/storage/v3/request_helper.hpp +++ b/src/storage/v3/request_helper.hpp @@ -13,8 +13,8 @@ #include -#include "storage/v3/bindings/ast/ast.hpp" #include "query/v2/requests.hpp" +#include "storage/v3/bindings/ast/ast.hpp" #include "storage/v3/bindings/pretty_print_ast_to_original_expression.hpp" #include "storage/v3/bindings/typed_value.hpp" #include "storage/v3/edge_accessor.hpp" @@ -133,11 +133,14 @@ std::vector> OrderByVertices(DbAccessor &dba, TIterable std::vector ordering; ordering.reserve(order_bys.size()); std::transform(order_bys.begin(), order_bys.end(), std::back_inserter(ordering), [](const auto &order_by) { - if (memgraph::msgs::OrderingDirection::ASCENDING == order_by.direction) { - return Ordering::ASC; + switch (order_by.direction) { + case memgraph::msgs::OrderingDirection::ASCENDING: + return Ordering::ASC; + case memgraph::msgs::OrderingDirection::DESCENDING: + return Ordering::DESC; + default: + LOG_FATAL("Unknown ordering direction"); } - MG_ASSERT(memgraph::msgs::OrderingDirection::DESCENDING == order_by.direction); - return Ordering::DESC; }); std::vector> ordered;