From ae032334410d46c94bcb6ca0cc22aa98ed6e5b94 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 31 Jul 2019 18:54:15 -0500 Subject: [PATCH] BSIP 40: Best build --- libraries/fc | 2 +- libraries/protocol/restriction_predicate.cpp | 44 +++++--------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/libraries/fc b/libraries/fc index 37f97ddf12..0d3409d593 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 37f97ddf12756c53cf00f6ec44068f680efdb186 +Subproject commit 0d3409d593d7b8993f1668a8fc12e8e8c1ada432 diff --git a/libraries/protocol/restriction_predicate.cpp b/libraries/protocol/restriction_predicate.cpp index fbfcf506ec..b1a529bfcc 100644 --- a/libraries/protocol/restriction_predicate.cpp +++ b/libraries/protocol/restriction_predicate.cpp @@ -347,73 +347,49 @@ struct attribute_assertion> { } }; -// slimmer accelerates build times by reducing the number of elements in the argument static variant to only those -// supported for a given function type. This reduces build time because it eliminates many options the compiler has -// to explore when visiting the argument variant to create a predicate -template -struct slimmer { - restriction_argument arg; - slimmer(restriction_argument&& arg) : arg(std::move(arg)) {} - using result_type = typelist::apply; - - template()>> - result_type do_cast(T&& content, short) { return result_type(content); } - template - result_type do_cast(T&&, long) { - FC_THROW_EXCEPTION(fc::assert_exception, "Invalid argument type for restriction function type"); - } - - template result_type operator()(T) { - return do_cast(std::move(arg.get()), short()); - } -}; - template object_restriction_predicate create_predicate_function(restriction_function func, restriction_argument arg) { try { - using typelist::runtime::dispatch; - using std::move; - using Arg = decltype(arg); switch(func) { case restriction::func_eq: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_ne: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_lt: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_le: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_gt: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_ge: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_in: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_not_in: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_has_all: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_has_none: { restriction_argument_visitor visitor; - return dispatch(Arg::list(), arg.which(), slimmer(move(arg))).visit(visitor); + return typelist::apply::import_from(std::move(arg)).visit(visitor); } case restriction::func_attr: FC_ASSERT(arg.which() == restriction_argument::tag>::value,