Remove useless templates from RWBackend functions

There's no need for templates as the code is only used with one
type. Changed the code to use std::advance as that might avoid a copy of
the iterator.
This commit is contained in:
Markus Mäkelä
2019-04-12 16:31:43 +03:00
parent 4131f09c16
commit b3399dccc4

View File

@ -17,6 +17,8 @@
#include <maxscale/protocol/mysql.h> #include <maxscale/protocol/mysql.h>
#include <maxscale/log.h> #include <maxscale/log.h>
using Iter = mxs::Buffer::iterator;
namespace maxscale namespace maxscale
{ {
@ -154,7 +156,6 @@ static inline bool have_next_packet(GWBUF* buffer)
return gwbuf_length(buffer) > len; return gwbuf_length(buffer) > len;
} }
template<class Iter>
uint64_t get_encoded_int(Iter it) uint64_t get_encoded_int(Iter it)
{ {
uint64_t len = *it++; uint64_t len = *it++;
@ -190,27 +191,30 @@ uint64_t get_encoded_int(Iter it)
return len; return len;
} }
template<class Iter>
Iter skip_encoded_int(Iter it) Iter skip_encoded_int(Iter it)
{ {
switch (*it) switch (*it)
{ {
case 0xfc: case 0xfc:
return std::next(it, 3); std::advance(it, 3);
break;
case 0xfd: case 0xfd:
return std::next(it, 4); std::advance(it, 4);
break;
case 0xfe: case 0xfe:
return std::next(it, 9); std::advance(it, 9);
break;
default: default:
return std::next(it); break;
} }
return it;
} }
template<class Iter> bool is_last_ok(Iter it)
uint64_t is_last_ok(Iter it)
{ {
++it; // Skip the command byte ++it; // Skip the command byte
it = skip_encoded_int(it); // Affected rows it = skip_encoded_int(it); // Affected rows
@ -220,8 +224,7 @@ uint64_t is_last_ok(Iter it)
return (status & SERVER_MORE_RESULTS_EXIST) == 0; return (status & SERVER_MORE_RESULTS_EXIST) == 0;
} }
template<class Iter> bool is_last_eof(Iter it)
uint64_t is_last_eof(Iter it)
{ {
std::advance(it, 3); // Skip the command byte and warning count std::advance(it, 3); // Skip the command byte and warning count
uint16_t status = *it++; uint16_t status = *it++;
@ -229,7 +232,7 @@ uint64_t is_last_eof(Iter it)
return (status & SERVER_MORE_RESULTS_EXIST) == 0; return (status & SERVER_MORE_RESULTS_EXIST) == 0;
} }
void RWBackend::process_reply_start(mxs::Buffer::iterator it) void RWBackend::process_reply_start(Iter it)
{ {
uint8_t cmd = *it; uint8_t cmd = *it;
m_local_infile_requested = false; m_local_infile_requested = false;