Fix std::max() call in Compression.cpp
[folly.git] / folly / io / Compression.cpp
index 5b83a6f0bff8b1665c43b9a7c8ded285d1e170b8..ae75b2a6a38a958c39ca4f6f32051eeeca21c6da 100644 (file)
@@ -565,7 +565,8 @@ std::unique_ptr<IOBuf> LZ4FrameCodec::doUncompress(
     growthSize = std::min(uncompressedLength, growthSize);
   } else {
     // Reduce growthSize for small data
-    const auto guessUncompressedLen = 4 * std::max(blockSize, in.size());
+    const auto guessUncompressedLen =
+        4 * std::max<uint64_t>(blockSize, in.size());
     growthSize = std::min(guessUncompressedLen, growthSize);
   }
   // Once LZ4_decompress() is called, the dctx_ cannot be reused until it
@@ -1599,14 +1600,16 @@ bool AutomaticCodec::canUncompress(
   return std::any_of(
       codecs_.begin(),
       codecs_.end(),
-      [data, uncompressedLength](const auto& codec) {
+      [data, uncompressedLength](std::unique_ptr<Codec> const& codec) {
         return codec->canUncompress(data, uncompressedLength);
       });
 }
 
 void AutomaticCodec::addCodecIfSupported(CodecType type) {
-  const bool present =
-      std::any_of(codecs_.begin(), codecs_.end(), [&type](const auto& codec) {
+  const bool present = std::any_of(
+      codecs_.begin(),
+      codecs_.end(),
+      [&type](std::unique_ptr<Codec> const& codec) {
         return codec->type() == type;
       });
   if (hasCodec(type) && !present) {
@@ -1631,17 +1634,20 @@ AutomaticCodec::AutomaticCodec(std::vector<std::unique_ptr<Codec>> customCodecs)
     checkCompatibleCodecs();
   }
   // Check that none of the codes are are null
-  DCHECK(std::none_of(codecs_.begin(), codecs_.end(), [](const auto& codec) {
-    return codec == nullptr;
-  }));
+  DCHECK(std::none_of(
+      codecs_.begin(), codecs_.end(), [](std::unique_ptr<Codec> const& codec) {
+        return codec == nullptr;
+      }));
 
-  needsUncompressedLength_ =
-      std::any_of(codecs_.begin(), codecs_.end(), [](const auto& codec) {
+  needsUncompressedLength_ = std::any_of(
+      codecs_.begin(), codecs_.end(), [](std::unique_ptr<Codec> const& codec) {
         return codec->needsUncompressedLength();
       });
 
   const auto it = std::max_element(
-      codecs_.begin(), codecs_.end(), [](const auto& lhs, const auto& rhs) {
+      codecs_.begin(),
+      codecs_.end(),
+      [](std::unique_ptr<Codec> const& lhs, std::unique_ptr<Codec> const& rhs) {
         return lhs->maxUncompressedLength() < rhs->maxUncompressedLength();
       });
   DCHECK(it != codecs_.end());