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:
@ -1367,6 +1367,7 @@ namespace maxscale
|
|||||||
std::string get_canonical(GWBUF* querybuf)
|
std::string get_canonical(GWBUF* querybuf)
|
||||||
{
|
{
|
||||||
std::string rval;
|
std::string rval;
|
||||||
|
rval.reserve(gwbuf_length(querybuf) - MYSQL_HEADER_LEN + 1);
|
||||||
mxs::Buffer buf(querybuf);
|
mxs::Buffer buf(querybuf);
|
||||||
|
|
||||||
enum state
|
enum state
|
||||||
|
|||||||
Reference in New Issue
Block a user