make `usingJEMalloc()` a constexpr when USE_JEMALLOC is defined v2017.11.27.00
authorBin Liu <binliu@fb.com>
Mon, 27 Nov 2017 06:07:41 +0000 (22:07 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 27 Nov 2017 06:24:12 +0000 (22:24 -0800)
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

folly/memory/Malloc.h

index 5bad7484a9a5dc2a524bb3d38e94a513061a45e7..e774dd0e907bffe80f1c473ac4ac872685906054 100644 (file)
@@ -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) {