Skip to content

Commit

Permalink
[folly] inline malloc feature tests when they are statically true
Browse files Browse the repository at this point in the history
Summary:
canSdallocx() and canNallocx() always return true if either USE_JEMALLOC
or USE_TCMALLOC is defined (and !FOLLY_SANITIZE).  When this occurs the
methods should not be marked FOLLY_NOINLINE.

Test Plan:
compile with USE_JEMALLOC
  • Loading branch information
nbronson committed Nov 21, 2022
1 parent 8878f7c commit caf400d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions folly/memory/Malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ FOLLY_NOINLINE inline bool usingTCMalloc() noexcept {
}
#endif

#if (defined(USE_JEMALLOC) || defined(USE_TCMALLOC)) && !FOLLY_SANITIZE
inline bool canSdallocx() noexcept {
return true;
}

inline bool canNallocx() noexcept {
return true;
}
#else
FOLLY_NOINLINE inline bool canSdallocx() noexcept {
static bool rv = usingJEMalloc() || usingTCMalloc();
return rv;
Expand All @@ -187,6 +196,7 @@ FOLLY_NOINLINE inline bool canNallocx() noexcept {
static bool rv = usingJEMalloc() || usingTCMalloc();
return rv;
}
#endif

inline size_t goodMallocSize(size_t minSize) noexcept {
if (minSize == 0) {
Expand Down

0 comments on commit caf400d

Please sign in to comment.