
Hi, Monty! On Apr 02, Michael Widenius wrote:
revision-id: 405a89353b2 (mariadb-10.5.2-542-g405a89353b2) parent(s): 2dd8d472fcc author: Michael Widenius <michael.widenius@gmail.com> committer: Michael Widenius <michael.widenius@gmail.com> timestamp: 2021-03-24 19:25:08 +0200 message:
Don't reset StringBuffers in loops when not needed
- Moved out creating StringBuffers in loops and instead create them outside and just reset the buffer if it was not allocated (to avoid a possible malloc/free for every entry)
diff --git a/sql/sql_string.h b/sql/sql_string.h index 29d01779b71..8df50ac5e66 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -1045,6 +1045,12 @@ class StringBuffer : public String { length(0); } + void set_buffer_if_not_allocated(CHARSET_INFO *cs) + { + if (is_alloced()) + Static_binary_string::set(buff, buff_sz);
it seems to be doing exactly the opposite of what the name suggests. It sets the buffer *if allocated*. Also, it looks logical to do length(0) here, so that this method would reset the StringBuffer to its initial state.
+ set_charset(cs); + } };
Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org