Use alloca rather than C99 stack allocated arrays
authorOrvid King <blah38621@gmail.com>
Thu, 8 Oct 2015 16:52:15 +0000 (09:52 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Thu, 8 Oct 2015 17:20:18 +0000 (10:20 -0700)
Summary: Because MSVC doesn't support the latter.
Closes https://github.com/facebook/folly/pull/271

Reviewed By: @meyering, @fredemmott

Differential Revision: D2283975

fb-gh-sync-id: d021f739ceead9998b8fedbbd95f22ec9fe949b2

folly/Format.cpp

index 0f67969c7b1df3f8ebe92f63effbd7152210ea2c..64e2cae56273771f47e1423fa1e6d81d6e70ee3a 100644 (file)
@@ -48,11 +48,11 @@ void FormatValue<double>::formatHelper(
   }
 
   // 2+: for null terminator and optional sign shenanigans.
-  char buf[2 + std::max({
-      (2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
-       DoubleToStringConverter::kMaxFixedDigitsAfterPoint),
-      (8 + DoubleToStringConverter::kMaxExponentialDigits),
-      (7 + DoubleToStringConverter::kMaxPrecisionDigits)})];
+  char buf[2 + std::max(
+      2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint +
+       DoubleToStringConverter::kMaxFixedDigitsAfterPoint,
+      std::max(8 + DoubleToStringConverter::kMaxExponentialDigits,
+      7 + DoubleToStringConverter::kMaxPrecisionDigits))];
   StringBuilder builder(buf + 1, static_cast<int> (sizeof(buf) - 1));
 
   char plusSign;