From 70171f97903752cdf4c910b94b5ee0e06570bb41 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Mon, 10 Jul 2017 22:32:18 +0200 Subject: [PATCH] GenericStringRef: move assert out of expression --- include/rapidjson/document.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 06451ad..3169bd4 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -308,7 +308,7 @@ struct GenericStringRef { */ #endif explicit GenericStringRef(const CharType* str) - : s(str), length(((RAPIDJSON_ASSERT(str != 0)), internal::StrLen(str))) {} + : s(str), length(NotNullStrLen(str)) {} //! Create constant string reference from pointer and length #ifndef __clang__ // -Wdocumentation @@ -331,6 +331,11 @@ struct GenericStringRef { const SizeType length; //!< length of the string (excluding the trailing NULL terminator) private: + SizeType NotNullStrLen(const CharType* str) { + RAPIDJSON_ASSERT(str != 0); + return internal::StrLen(str); + } + /// Empty string - used when passing in a NULL pointer static const Ch emptyString[];