From 5d6af189f13678ae1becad9b1438455a25256102 Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Tue, 16 Nov 2021 09:59:48 -0500 Subject: [PATCH] Use target.capacity() even with std::string --- include/spdlog/details/os-inl.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index 9b2ef0d8..e4cddd41 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -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(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(target.capacity()); if (str_size + 1 > result_size) -#endif { result_size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), str_size, NULL, 0); }