From bb67320752baa0c6570df18d2ec84f6b62d7b59b Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Sat, 3 Oct 2020 23:11:03 +0800 Subject: [PATCH] Removed dead code from a macro in zmalloc.cpp I think the compiler would have removed this no-op anyways but it definitely wasted me some 30 minutes on this :( I was hoping I could remove the branch through some bit-hacking but apparently its dead code :). Oh well, its 30 minutes of refreshing bit hacking. Signed-off-by: Hanif Bin Ariffin Former-commit-id: 8171e6de13311e3ad2e87c32d63060dcf3bd6055 --- src/zmalloc.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/zmalloc.cpp b/src/zmalloc.cpp index e3d364a97..f88fee638 100644 --- a/src/zmalloc.cpp +++ b/src/zmalloc.cpp @@ -83,17 +83,8 @@ static_assert((PREFIX_SIZE % 16) == 0, "Our prefix must be modulo 16-bytes or ou #define realloc(ptr,size,type) realloc(ptr,size) #endif -#define update_zmalloc_stat_alloc(__n) do { \ - size_t _n = (__n); \ - if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1)); \ - atomicIncr(used_memory,__n); \ -} while(0) - -#define update_zmalloc_stat_free(__n) do { \ - size_t _n = (__n); \ - if (_n&(sizeof(long)-1)) _n += sizeof(long)-(_n&(sizeof(long)-1)); \ - atomicDecr(used_memory,__n); \ -} while(0) +#define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n)) +#define update_zmalloc_stat_free(__n) atomicDecr(used_memory,(__n)) static size_t used_memory = 0; pthread_mutex_t used_memory_mutex = PTHREAD_MUTEX_INITIALIZER;