From 7a2e6e79c64d322875f6ad565fc60024c9f40752 Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Thu, 10 Jul 2014 16:46:42 +0200 Subject: [PATCH] StrLen: align implementations There are two copies of `StrLen` in the RapidJSON code base * strfunc.h: rapidjson::internal::StrLen * unittest.h: Strlen To hide a warning on MSVC, align both implementations to use 'unsigned/SizeType' as return type and add an explicit cast. --- include/rapidjson/internal/strfunc.h | 3 +-- test/unittest/unittest.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/rapidjson/internal/strfunc.h b/include/rapidjson/internal/strfunc.h index 47b8ac0..0a20c56 100644 --- a/include/rapidjson/internal/strfunc.h +++ b/include/rapidjson/internal/strfunc.h @@ -13,8 +13,7 @@ namespace internal { template inline SizeType StrLen(const Ch* s) { const Ch* p = s; - while (*p != '\0') - ++p; + while (*p) ++p; return SizeType(p - s); } diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index 75d2bc4..0234319 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -27,10 +27,10 @@ #endif template -inline size_t StrLen(const Ch* s) { +inline unsigned StrLen(const Ch* s) { const Ch* p = s; while (*p) p++; - return p - s; + return unsigned(p - s); } template