Skip to content

Commit 55f8a32

Browse files
committed
Remove broken templatized string length optimization
It did not support char arrays.
1 parent 84a0356 commit 55f8a32

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

include/rapidjson/writer.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ class Writer {
199199
return EndValue(WriteString(str, length));
200200
}
201201

202-
template <typename T>
203-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) String(const T* str, SizeType length, bool copy = false) {
202+
bool String(const Ch* str, SizeType length, bool copy = false) {
204203
RAPIDJSON_ASSERT(str != 0);
205204
(void)copy;
206205
Prefix(kStringType);
@@ -219,8 +218,7 @@ class Writer {
219218
return WriteStartObject();
220219
}
221220

222-
template <typename T>
223-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) Key(const T* str, SizeType length, bool copy = false) { return String(str, length, copy); }
221+
bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); }
224222

225223
bool EndObject(SizeType memberCount = 0) {
226224
(void)memberCount;
@@ -250,23 +248,9 @@ class Writer {
250248
//@{
251249

252250
//! Simpler but slower overload.
253-
template <typename T>
254-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) String(const T* const& str) { return String(str, internal::StrLen(str)); }
255-
template <typename T>
256-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) Key(const T* const& str) { return Key(str, internal::StrLen(str)); }
251+
bool String(const Ch* const& str) { return String(str, internal::StrLen(str)); }
252+
bool Key(const Ch* const& str) { return Key(str, internal::StrLen(str)); }
257253

258-
//! The compiler can give us the length of quoted strings for free.
259-
template <typename T, size_t N>
260-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) String(const T (&str)[N]) {
261-
RAPIDJSON_ASSERT(str[N-1] == '\0'); // you must pass in a null-terminated string (quoted constant strings are always null-terminated)
262-
return String(str, N-1);
263-
}
264-
template <typename T, size_t N>
265-
RAPIDJSON_ENABLEIF_RETURN((internal::IsSame<Ch, T>), (bool)) Key(const T (&str)[N]) {
266-
RAPIDJSON_ASSERT(str[N-1] == '\0'); // you must pass in a null-terminated string (quoted constant strings are always null-terminated)
267-
return Key(str, N-1);
268-
}
269-
270254
//@}
271255

272256
//! Write a raw JSON value.

0 commit comments

Comments
 (0)