Commit b9a67dd9 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Pull out a local variable in MMapAlloc

Summary:
[Folly] Pull out a local variable in `MMapAlloc`.

Moves the conditional compilation out of a compilcated expression and into a separate full-statement by itself.

Reviewed By: Orvid

Differential Revision: D9598437

fbshipit-source-id: 770c835f729e72b880aadcefb8aae7ead2754bd9
parent c1964a1f
......@@ -40,18 +40,17 @@ class MMapAlloc {
void* allocate(size_t size) {
auto len = computeSize(size);
int extraflags = 0;
#if defined(MAP_POPULATE)
extraflags |= MAP_POPULATE;
#endif
// MAP_HUGETLB is a perf win, but requires cooperation from the
// deployment environment (and a change to computeSize()).
void* mem = static_cast<void*>(mmap(
nullptr,
len,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS
#ifdef MAP_POPULATE
|
MAP_POPULATE
#endif
,
MAP_PRIVATE | MAP_ANONYMOUS | extraflags,
-1,
0));
if (mem == reinterpret_cast<void*>(-1)) {
......
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