diff --git a/include/jemalloc/internal/tsd.h b/include/jemalloc/internal/tsd.h index 2355f9c6..5df5f673 100644 --- a/include/jemalloc/internal/tsd.h +++ b/include/jemalloc/internal/tsd.h @@ -226,7 +226,8 @@ a_name##tsd_set(a_type *val) \ { \ \ assert(a_name##tsd_booted); \ - a_name##tsd_tls = (*val); \ + if (likely(&a_name##tsd_tls != val)) \ + a_name##tsd_tls = (*val); \ if (a_cleanup != malloc_tsd_no_cleanup) \ a_name##tsd_initialized = true; \ } @@ -277,7 +278,8 @@ a_name##tsd_set(a_type *val) \ { \ \ assert(a_name##tsd_booted); \ - a_name##tsd_tls = (*val); \ + if (likely(&a_name##tsd_tls != val)) \ + a_name##tsd_tls = (*val); \ if (a_cleanup != malloc_tsd_no_cleanup) { \ if (pthread_setspecific(a_name##tsd_tsd, \ (void *)(&a_name##tsd_tls))) { \ @@ -409,7 +411,8 @@ a_name##tsd_set(a_type *val) \ \ assert(a_name##tsd_booted); \ wrapper = a_name##tsd_wrapper_get(); \ - wrapper->val = *(val); \ + if (likely(&wrapper->val != val)) \ + wrapper->val = *(val); \ if (a_cleanup != malloc_tsd_no_cleanup) \ wrapper->initialized = true; \ } @@ -537,7 +540,8 @@ a_name##tsd_set(a_type *val) \ \ assert(a_name##tsd_booted); \ wrapper = a_name##tsd_wrapper_get(); \ - wrapper->val = *(val); \ + if (likely(&wrapper->val != val)) \ + wrapper->val = *(val); \ if (a_cleanup != malloc_tsd_no_cleanup) \ wrapper->initialized = true; \ }