From 04df911915ecfcbc5e6b13fdab1b86f825ed1938 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Sat, 3 Oct 2015 15:38:33 -0700 Subject: [PATCH] tell compiler that non-empty hooks are unlikely --- src/malloc_hook-inl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/malloc_hook-inl.h b/src/malloc_hook-inl.h index 9e74ec8..dbf4d46 100644 --- a/src/malloc_hook-inl.h +++ b/src/malloc_hook-inl.h @@ -44,6 +44,8 @@ #include "base/basictypes.h" #include +#include "common.h" // for UNLIKELY + namespace base { namespace internal { // Capacity of 8 means that HookList is 9 words. @@ -121,7 +123,7 @@ inline MallocHook::NewHook MallocHook::GetNewHook() { } inline void MallocHook::InvokeNewHook(const void* p, size_t s) { - if (!base::internal::new_hooks_.empty()) { + if (UNLIKELY(!base::internal::new_hooks_.empty())) { InvokeNewHookSlow(p, s); } } @@ -132,7 +134,7 @@ inline MallocHook::DeleteHook MallocHook::GetDeleteHook() { } inline void MallocHook::InvokeDeleteHook(const void* p) { - if (!base::internal::delete_hooks_.empty()) { + if (UNLIKELY(!base::internal::delete_hooks_.empty())) { InvokeDeleteHookSlow(p); } }