Pre-allocate return value in get_canonical

Since we know the worst-case size of a canonical statement is the size of
the query string, we can reduce the number of memory allocations to one in
the get_canonical function.
This commit is contained in:
Markus Mäkelä 2018-12-08 11:27:39 +02:00
parent e386dcba88
commit 208a1d011e
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -1367,6 +1367,7 @@ namespace maxscale
std::string get_canonical(GWBUF* querybuf)
{
std::string rval;
rval.reserve(gwbuf_length(querybuf) - MYSQL_HEADER_LEN + 1);
mxs::Buffer buf(querybuf);
enum state