From 2ac3121af2767186c489054db5d4871d04b8eef4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Feb 2020 16:42:23 +0100 Subject: perfschema - various collateral cleanups and small changes --- sql/sql_array.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sql/sql_array.h') diff --git a/sql/sql_array.h b/sql/sql_array.h index 44dde114d62..70aeaabc8ec 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -170,6 +170,11 @@ public: return ((const Elem*)array.buffer) + array.elements - 1; } + const Elem *end() const + { + return back() + 1; + } + /// @returns pointer to n-th element Elem *get_pos(size_t idx) { @@ -182,7 +187,6 @@ public: return ((const Elem*)array.buffer) + idx; } - /** @retval false ok @retval true OOM, @c my_error() has been called. @@ -240,10 +244,16 @@ public: freeze_size(&array); } + bool reserve(size_t new_size) + { + return allocate_dynamic(&array, (uint)new_size); + } + + bool resize(size_t new_size, Elem default_val) { size_t old_size= elements(); - if (unlikely(allocate_dynamic(&array, (uint)new_size))) + if (reserve(new_size)) return true; if (new_size > old_size) -- cgit v1.2.1