From 55f8a32020ae45101c709b826818d429c720dff4 Mon Sep 17 00:00:00 2001 From: John Stiles Date: Sun, 12 Mar 2017 23:47:59 -0700 Subject: [PATCH] Remove broken templatized string length optimization It did not support char arrays. --- include/rapidjson/writer.h | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/include/rapidjson/writer.h b/include/rapidjson/writer.h index 7a0af39..b83b68e 100644 --- a/include/rapidjson/writer.h +++ b/include/rapidjson/writer.h @@ -199,8 +199,7 @@ public: return EndValue(WriteString(str, length)); } - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) String(const T* str, SizeType length, bool copy = false) { + bool String(const Ch* str, SizeType length, bool copy = false) { RAPIDJSON_ASSERT(str != 0); (void)copy; Prefix(kStringType); @@ -219,8 +218,7 @@ public: return WriteStartObject(); } - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) Key(const T* str, SizeType length, bool copy = false) { return String(str, length, copy); } + bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); } bool EndObject(SizeType memberCount = 0) { (void)memberCount; @@ -250,23 +248,9 @@ public: //@{ //! Simpler but slower overload. - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) String(const T* const& str) { return String(str, internal::StrLen(str)); } - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) Key(const T* const& str) { return Key(str, internal::StrLen(str)); } + bool String(const Ch* const& str) { return String(str, internal::StrLen(str)); } + bool Key(const Ch* const& str) { return Key(str, internal::StrLen(str)); } - //! The compiler can give us the length of quoted strings for free. - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) String(const T (&str)[N]) { - RAPIDJSON_ASSERT(str[N-1] == '\0'); // you must pass in a null-terminated string (quoted constant strings are always null-terminated) - return String(str, N-1); - } - template - RAPIDJSON_ENABLEIF_RETURN((internal::IsSame), (bool)) Key(const T (&str)[N]) { - RAPIDJSON_ASSERT(str[N-1] == '\0'); // you must pass in a null-terminated string (quoted constant strings are always null-terminated) - return Key(str, N-1); - } - //@} //! Write a raw JSON value.