From: Bin Liu Date: Mon, 27 Nov 2017 06:07:41 +0000 (-0800) Subject: make `usingJEMalloc()` a constexpr when USE_JEMALLOC is defined X-Git-Tag: v2017.11.27.00^0 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=ee207f19892790e091082cc7c7ab8c5df0398061;ds=sidebyside make `usingJEMalloc()` a constexpr when USE_JEMALLOC is defined Summary: This would save some function calls and reduce code size if we know we will use jemalloc. Reviewed By: yfeldblum Differential Revision: D6411810 fbshipit-source-id: 9db471678e473945f5f00354c0a1285ecdb91de6 --- diff --git a/folly/memory/Malloc.h b/folly/memory/Malloc.h index 5bad7484..e774dd0e 100644 --- a/folly/memory/Malloc.h +++ b/folly/memory/Malloc.h @@ -147,6 +147,11 @@ namespace folly { /** * Determine if we are using jemalloc or not. */ +#ifdef USE_JEMALLOC +inline bool usingJEMalloc() noexcept { + return true; +} +#else FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept { // Checking for rallocx != nullptr is not sufficient; we may be in a // dlopen()ed module that depends on libjemalloc, so rallocx is resolved, but @@ -194,6 +199,7 @@ FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept { return result; } +#endif inline size_t goodMallocSize(size_t minSize) noexcept { if (minSize == 0) {