From da85ad798708d045e7ba1963172daf81aeb80ab9 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 14 Aug 2020 18:56:56 +0300 Subject: Optimize Sql_alloc - Remove 'dummy_for_valgrind' overrun marker as this doesn't help much. The element also distorts the sizes of objects a bit, which makes it harder to calculate gain in object sizes when doing size optimizations. - Replace usage of thd_get_current_thd() with _current_thd() - Avoid one extra call indirection when using thd_get_current_thd(), which is used by Sql_alloc, by replacing it with _current_thd() --- sql/sql_alloc.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'sql/sql_alloc.h') diff --git a/sql/sql_alloc.h b/sql/sql_alloc.h index f475ecdff73..f5d2d4e8b1a 100644 --- a/sql/sql_alloc.h +++ b/sql/sql_alloc.h @@ -18,20 +18,18 @@ #include /* alloc_root, MEM_ROOT, TRASH */ -THD *thd_get_current_thd(); - -/* mysql standard class memory allocator */ +/* MariaDB standard class memory allocator */ class Sql_alloc { public: static void *operator new(size_t size) throw () { - return thd_alloc(thd_get_current_thd(), size); + return thd_alloc(_current_thd(), size); } static void *operator new[](size_t size) throw () { - return thd_alloc(thd_get_current_thd(), size); + return thd_alloc(_current_thd(), size); } static void *operator new[](size_t size, MEM_ROOT *mem_root) throw () { return alloc_root(mem_root, size); } @@ -42,9 +40,5 @@ public: static void operator delete[](void *, MEM_ROOT *) { /* never called */ } static void operator delete[](void *ptr, size_t size) { TRASH_FREE(ptr, size); } -#ifdef HAVE_valgrind - bool dummy_for_valgrind; - inline Sql_alloc() :dummy_for_valgrind(0) {} -#endif }; #endif /* SQL_ALLOC_INCLUDED */ -- cgit v1.2.1