Use target.capacity() even with std::string

This commit is contained in:
Charles Milette 2021-11-16 09:59:48 -05:00
parent 484bf07379
commit 5d6af189f1

View File

@ -462,12 +462,8 @@ SPDLOG_INLINE void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
return;
}
#ifdef SPDLOG_USE_STD_FORMAT
int result_size = 0;
#else
int result_size = static_cast<int>(target.capacity());
if ((wstr_size + 1) * 2 > result_size)
#endif
{
result_size = ::WideCharToMultiByte(CP_UTF8, 0, wstr.data(), wstr_size, NULL, 0, NULL, NULL);
}
@ -501,12 +497,8 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
return;
}
#ifdef SPDLOG_USE_STD_FORMAT
int result_size = 0;
#else
int result_size = static_cast<int>(target.capacity());
if (str_size + 1 > result_size)
#endif
{
result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0);
}