#define FOLLY_NULLABLE
#define FOLLY_NONNULL
#endif
+
+/**
+ * "Cold" indicates to the compiler that a function is only expected to be
+ * called from unlikely code paths. It can affect decisions made by the
+ * optimizer both when processing the function body and when analyzing
+ * call-sites.
+ */
+#if __GNUC__
+#define FOLLY_COLD __attribute__((__cold__))
+#else
+#define FOLLY_COLD
+#endif
#include <glog/logging.h>
+#include <folly/CppAttributes.h>
#include <folly/Likely.h>
#include <folly/Optional.h>
#include <folly/Portability.h>
Unexpected(Unexpected&&) = default;
Unexpected& operator=(const Unexpected&) = default;
Unexpected& operator=(Unexpected&&) = default;
- constexpr /* implicit */ Unexpected(const Error& err) : error_(err) {}
- constexpr /* implicit */ Unexpected(Error&& err) : error_(std::move(err)) {}
+ FOLLY_COLD constexpr /* implicit */ Unexpected(const Error& err)
+ : error_(err) {}
+ FOLLY_COLD constexpr /* implicit */ Unexpected(Error&& err)
+ : error_(std::move(err)) {}
template <class Other FOLLY_REQUIRES_TRAILING(
std::is_constructible<Error, Other&&>::value)>