From 37d104a2c5636de7cdb8d9b1749b08dce1ad9d76 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 3 May 2019 09:53:30 +0200 Subject: [PATCH] max_sizeof(...) now does a divide a conquer to reduce recursion depth --- lib/include/srslte/asn1/asn1_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/include/srslte/asn1/asn1_utils.h b/lib/include/srslte/asn1/asn1_utils.h index ceec14995..dcff77ec9 100644 --- a/lib/include/srslte/asn1/asn1_utils.h +++ b/lib/include/srslte/asn1/asn1_utils.h @@ -789,9 +789,9 @@ union alignment_t { }; #define MAX2(a, b) ((a) > (b)) ? (a) : (b) template -constexpr size_t max_size(It b, It e) +constexpr size_t max_size(const It b, const It e) { - return (b != e) ? MAX2(max_size((b + 1), e), *b) : 0; + return ((b == e) ? 0 : ((b + 1 == e) ? *b : MAX2(max_size(b, b + (e - b) / 2), max_size(b + (e - b) / 2, e)))); } constexpr size_t max_sizeof(const std::initializer_list& l) {