1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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()
This commit is contained in:
Monty
2020-08-14 18:56:56 +03:00
committed by Sergei Golubchik
parent c76eabfb5e
commit da85ad7987
6 changed files with 11 additions and 23 deletions

View File

@ -18,20 +18,18 @@
#include <my_sys.h> /* 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 */