diff --git a/driver/format/ODBCDriver2.cpp b/driver/format/ODBCDriver2.cpp index 967483b5e..af7324937 100644 --- a/driver/format/ODBCDriver2.cpp +++ b/driver/format/ODBCDriver2.cpp @@ -76,7 +76,7 @@ void ODBCDriver2ResultSet::readValue(std::string & dest, bool * is_null) { readSize(size); if (size >= 0) { - folly::resizeWithoutInitialization(dest, size); + resize_without_initialization(dest, size); if (is_null) *is_null = false; diff --git a/driver/format/RowBinaryWithNamesAndTypes.cpp b/driver/format/RowBinaryWithNamesAndTypes.cpp index 1958d1e75..655fe8b71 100644 --- a/driver/format/RowBinaryWithNamesAndTypes.cpp +++ b/driver/format/RowBinaryWithNamesAndTypes.cpp @@ -88,7 +88,8 @@ void RowBinaryWithNamesAndTypesResultSet::readValue(std::string & res) { } void RowBinaryWithNamesAndTypesResultSet::readValue(std::string & dest, const std::uint64_t size) { - folly::resizeWithoutInitialization(dest, size); + resize_without_initialization(dest, size); + try { stream.read(dest.data(), dest.size()); } diff --git a/driver/utils/utils.h b/driver/utils/utils.h index 338fb5032..54d10d51a 100755 --- a/driver/utils/utils.h +++ b/driver/utils/utils.h @@ -9,8 +9,6 @@ # include "driver/utils/iostream_debug_helpers.h" #endif -#include - #include #include #include @@ -35,6 +33,13 @@ #include +#if defined(_MSC_VER) && _MSC_VER > 1916 // Not supported yet for Visual Studio 2019 and later. +# define resize_without_initialization(container, size) container.resize(size) +#else +# include +# define resize_without_initialization(container, size) folly::resizeWithoutInitialization(container, size) +#endif + class Environment; class Connection; class Descriptor; @@ -230,23 +235,23 @@ class AmortizedIStreamReader if (free_capacity < to_read) { // Reallocation is unavoidable. Compact the buffer while doing it. if (avail > 0) { decltype(buffer_) tmp; - folly::resizeWithoutInitialization(tmp, avail + to_read); + resize_without_initialization(tmp, avail + to_read); std::memcpy(&tmp[0], &buffer_[offset_], avail); buffer_.swap(tmp); } else { buffer_.clear(); - folly::resizeWithoutInitialization(buffer_, to_read); + resize_without_initialization(buffer_, to_read); } } else { // Compacting the buffer is enough. std::memmove(&buffer_[0], &buffer_[offset_], avail); - folly::resizeWithoutInitialization(buffer_, avail + to_read); + resize_without_initialization(buffer_, avail + to_read); } offset_ = 0; } else { - folly::resizeWithoutInitialization(buffer_, buffer_.size() + to_read); + resize_without_initialization(buffer_, buffer_.size() + to_read); } raw_stream_.read(&buffer_[offset_ + avail], to_read);