From 1a503b27864a0e1b90ef8e66a830e50a68f38246 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 28 Aug 2017 15:33:03 +0200 Subject: [PATCH] don't flush dbug buffers for every assert only do it before crashing. Otherwise it introduces a noticable slowdown and, most importantly, changes errno, when the caller doesn't expect it. --- include/my_dbug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/my_dbug.h b/include/my_dbug.h index 1e0aaf680f8..b9194428f18 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -102,8 +102,8 @@ extern const char* _db_get_func_(void); #define DBUG_END() _db_end_ () #define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_UNLOCK_FILE _db_unlock_file_() -#define DBUG_ASSERT(A) ( _db_flush_(), assert(A) ) -#define DBUG_SLOW_ASSERT(A) ( _db_flush_(), assert(A) ) +#define DBUG_ASSERT(A) do { if (!(A)) { _db_flush_(); assert(A); }} while (0) +#define DBUG_SLOW_ASSERT(A) DBUG_ASSERT(A) #define DBUG_ASSERT_EXISTS #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len)) #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))