Commit dcd9f349 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Move AlignedSysAllocator computation of max

Summary: [Folly] Move `AlignedSysAllocator` computation of max value over input alignment values from two places to a single place.

Differential Revision: D19229096

fbshipit-source-id: 4e95c7b7e0afe99c37116150184eb180683c7d13
parent 3b29cdba
......@@ -434,8 +434,8 @@ class DefaultAlign {
assert(!(align_ < sizeof(void*)) && bool("bad align: too small"));
assert(!(align_ & (align_ - 1)) && bool("bad align: not power-of-two"));
}
std::size_t operator()(std::size_t align) const noexcept {
return align_ < align ? align : align_;
std::size_t operator()() const noexcept {
return align_;
}
friend bool operator==(Self const& a, Self const& b) noexcept {
......@@ -454,8 +454,8 @@ class FixedAlign {
using Self = FixedAlign<Align>;
public:
constexpr std::size_t operator()(std::size_t align) const noexcept {
return Align < align ? align : Align;
constexpr std::size_t operator()() const noexcept {
return Align;
}
friend bool operator==(Self const&, Self const&) noexcept {
......@@ -496,7 +496,7 @@ class AlignedSysAllocator : private Align {
public:
static_assert(std::is_nothrow_copy_constructible<Align>::value, "");
static_assert(is_nothrow_invocable_r_v<std::size_t, Align, std::size_t>, "");
static_assert(is_nothrow_invocable_r_v<std::size_t, Align>, "");
using value_type = T;
......@@ -521,7 +521,7 @@ class AlignedSysAllocator : private Align {
T* allocate(size_t count) {
using lifted = typename detail::lift_void_to_char<T>::type;
auto const a = align()(alignof(lifted));
auto const a = align()() < alignof(lifted) ? alignof(lifted) : align()();
auto const p = aligned_malloc(sizeof(lifted) * count, a);
if (!p) {
if (FOLLY_UNLIKELY(errno != ENOMEM)) {
......
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