Commit e80c094b authored by Nick Terrell's avatar Nick Terrell Committed by Facebook GitHub Bot

Drop support for zstd versions < 1.4.0

Summary:
Dropping support for earlier zstd versions allows us to remove all of the version check logic.
Zstd-1.4.0 was released in April 2019, and it stabilized a large portion of our API.

Reviewed By: yfeldblum, Cyan4973

Differential Revision: D26585060

fbshipit-source-id: 3e8bd3aa1930c993cc0f2e8fc147db66de9dfdda
parent c1406fae
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#include <folly/compression/Utils.h> #include <folly/compression/Utils.h>
static_assert( static_assert(
ZSTD_VERSION_NUMBER >= 10302, ZSTD_VERSION_NUMBER >= 10400,
"zstd-1.3.2 is the minimum supported zstd version."); "zstd-1.4.0 is the minimum supported zstd version.");
using folly::io::compression::detail::dataStartsWithLE; using folly::io::compression::detail::dataStartsWithLE;
using folly::io::compression::detail::prefixToStringLE; using folly::io::compression::detail::prefixToStringLE;
...@@ -43,22 +43,6 @@ namespace io { ...@@ -43,22 +43,6 @@ namespace io {
namespace zstd { namespace zstd {
namespace { namespace {
// Compatibility helpers for zstd versions < 1.4.0
#if ZSTD_VERSION_NUMBER < 10400
#define ZSTD_CCtxParams_setParameter ZSTD_CCtxParam_setParameter
#endif
// Compatibility helpers for zstd versions < 1.3.8.
#if ZSTD_VERSION_NUMBER < 10308
#define ZSTD_compressStream2 ZSTD_compress_generic
#define ZSTD_c_compressionLevel ZSTD_p_compressionLevel
#define ZSTD_c_contentSizeFlag ZSTD_p_contentSizeFlag
#endif
size_t zstdThrowIfError(size_t rc) { size_t zstdThrowIfError(size_t rc) {
if (!ZSTD_isError(rc)) { if (!ZSTD_isError(rc)) {
return rc; return rc;
...@@ -237,16 +221,7 @@ Options::Options(int level) : params_(ZSTD_createCCtxParams()), level_(level) { ...@@ -237,16 +221,7 @@ Options::Options(int level) : params_(ZSTD_createCCtxParams()), level_(level) {
if (params_ == nullptr) { if (params_ == nullptr) {
throw std::bad_alloc{}; throw std::bad_alloc{};
} }
#if ZSTD_VERSION_NUMBER >= 10304
zstdThrowIfError(ZSTD_CCtxParams_init(params_.get(), level)); zstdThrowIfError(ZSTD_CCtxParams_init(params_.get(), level));
#else
zstdThrowIfError(ZSTD_initCCtxParams(params_.get(), level));
set(ZSTD_c_contentSizeFlag, 1);
#endif
// zstd-1.3.4 is buggy and only disables Huffman decompression for negative
// compression levels if this call is present. This call is begign in other
// versions.
set(ZSTD_c_compressionLevel, level);
} }
void Options::set(ZSTD_cParameter param, unsigned value) { void Options::set(ZSTD_cParameter param, unsigned value) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment