From b67ff2fb11307dfe03926f5433175fb67072cc64 Mon Sep 17 00:00:00 2001 From: fuzhufang Date: Thu, 14 Jul 2016 17:50:48 +0800 Subject: [PATCH] if define RAPIDJSON_HAS_STDSTRING, FindMember use std::string, but it also use internal::StrLen to get the string lengtht, when it call FindMember(StringRef(name)). Now use GenericValue construct it, then can use the std::string.size. now it will be faster. --- include/rapidjson/document.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 783479cb3..e3e20dfbd 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -1169,8 +1169,8 @@ class GenericValue { \return Iterator to member, if it exists. Otherwise returns \ref MemberEnd(). */ - MemberIterator FindMember(const std::basic_string& name) { return FindMember(StringRef(name)); } - ConstMemberIterator FindMember(const std::basic_string& name) const { return FindMember(StringRef(name)); } + MemberIterator FindMember(const std::basic_string& name) { return FindMember(GenericValue(StringRef(name))); } + ConstMemberIterator FindMember(const std::basic_string& name) const { return FindMember(GenericValue(StringRef(name))); } #endif //! Add a member (name-value pair) to the object.