From 459414f095f44c4e14d416fe068e71bcda4e0091 Mon Sep 17 00:00:00 2001 From: Zain Ruan Date: Sun, 3 Jul 2022 16:18:02 -0400 Subject: [PATCH] Fix a performance bug when deserializing C arrays Without the proposed change, cereal will deserialize the C-array using the slow-path serializeArray(), i.e., the one that deserializes the array element by element, even though the array is arithmetic. --- include/cereal/types/common.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cereal/types/common.hpp b/include/cereal/types/common.hpp index 4ea67e2e..c761ad46 100644 --- a/include/cereal/types/common.hpp +++ b/include/cereal/types/common.hpp @@ -121,7 +121,8 @@ namespace cereal CEREAL_SERIALIZE_FUNCTION_NAME(Archive & ar, T & array) { common_detail::serializeArray( ar, array, - std::integral_constant, Archive>::value && + std::integral_constant, Archive>::value || + traits::is_input_serializable, Archive>::value) && std::is_arithmetic::type>::value>() ); } } // namespace cereal